0

i have 2 main components

  • SurveyList, used to display all survey data

  • Survey, used to update survey data

when i click edit button in survey list, it shows selected survey id on url, but not able to pass to Survey Component

Like this

enter image description here

this is my Route for SurveyComponent

 <Route path="/survey/:id" component={Survey} />

And here is Link to

 <Link to={`/survey/${currentsurvey.id}`/>

I also tried different methods fot this, but none of them are working.

James Z
  • 12,209
  • 10
  • 24
  • 44
salik saleem
  • 769
  • 5
  • 25

2 Answers2

0

You can see in the docs how to access the :id inside the route component here

import {
  useParams
} from "react-router-dom";
...
...

  const { id } = useParams();
...
...
Tasos
  • 1,880
  • 13
  • 19
-1

Add Exact to the Route

<Route exact path="/survey/:id" component={Survey} />
suresh
  • 9
  • 3