function ArticleList() {
        // get the parent url and the matched path
        let { path, url } = useRouteMatch();
      
        return (
          <div>
            <h2>Articles</h2>
            <ul>
              <li>
                <Link to={`${url}/pointer`}>C with pointer</Link>
              </li>
              <li>
                <Link to={`${url}/basics`}>C basics</Link>
              </li>
            </ul>
      
            <Switch>
              <Route exact path={path}>
                <h3>Please select an article.</h3>
              </Route>
              <Route path={`${path}/:article`}>
                <Article />
              </Route>
            </Switch>
          </div>
        );
      }
      function Article() {
        let { article } = useParams();
        return (
          <div>
            <h3>The select article is {article}</h3>
          </div>
        );
      }

      Javascript language logo
      your recipe card header background
      Function component

      React Project

      Use RouteMatch() to get the parent URL and the matched path. Use Article() to get the value of article.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.