Sign in
Log inSign up

How is match from React Router provided?

Robert Vargas's photo
Robert Vargas
·Oct 10, 2017

From a snippet from the creators of React Router, im trying to figure out how is match being provided? Is it coming from React Router? if so how? Is that destructuring in a function parameter? is it passed as props? As you can probably tell im not even sure on how to clearly ask this question since im not sure on what don't i understand. Links or explanations will be appreciated!


reacttraining.com/react-router/web/api/match

const Topics = ({ match }) => (
  <div>
    <h2>Topics</h2>
    <ul>
      <li>
        <Link to={`${match.url}/rendering`}>
          Rendering with React
        </Link>
      </li>
      <li>
        <Link to={`${match.url}/components`}>
          Components
        </Link>
      </li>
      <li>
        <Link to={`${match.url}/props-v-state`}>
          Props v. State
        </Link>
      </li>
    </ul>

    <Route path={`${match.url}/:topicId`} component={Topic}/>
    <Route exact path={match.url} render={() => (
      <h3>Please select a topic.</h3>
    )}/>
  </div>
)
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct