Detailed explanation of how react obtains Routing Parameters in components, detailed explanation of react component Routing
Route Parameters
If we have a lot of list pages, these pages have different dynamic content and other page parts are the same, how do we configure routes and components at this time?
In this scenario, you need to use the routing Parameter Function to add a route configuration containing parameters.
Import List from './component/list'; <Route path = "list/: id" component = {list}/>
Note: id in the path attribute is the route parameter (param ). Let's take a look at the components on the List page.
/List corresponds to list. jsimport React from 'react '; class List extends react. component {render () {return (<div>
In the List component, you can directly use this. props. params. id to access the actual parameter value (here the id key corresponds to the defined path: id), React Router transmits the route data to the page component through props, in this way, you can easily access route-related data.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.