Detailed explanation of how react obtains Routing Parameters in components, detailed explanation of react component Routing

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.