React Extract Param From Url
I'm using react-router for routing . I've used NavLink and Route components like this:
Solution 1:
When using component=
..., your component will be passed the route props.
In particular, you'll want to access the match
object:
constBrokerDetails = ({match}) => <div>{JSON.stringify(match.params)}</div>;
should show you all the parameters; match.params.id
would be the id
parameter.
Solution 2:
If you try to access props.Id
won't work because it isn't in that location.
When you try to access params from an URL, which is passed using 'React-router-dom', then the way to access the props is match.params.id
Post a Comment for "React Extract Param From Url"