how to do routes react js

import React from "react";
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link
} from "react-router-dom";

export default function App() {
  return (
    <Router>
      <div>
        <nav>
          <ul>
            <li>
              <Link to="/">Home</Link>
            </li>
            <li>
              <Link to="/about">About</Link>
            </li>
            <li>
              <Link to="/users">Users</Link>
            </li>
          </ul>
        </nav>

        {/* A <Switch> looks through its children <Route>s and
            renders the first one that matches the current URL. */}
        <Switch>
          <Route path="/about">
            <About />
          </Route>
          <Route path="/users">
            <Users />
          </Route>
          <Route path="/">
            <Home />
          </Route>
        </Switch>
      </div>
    </Router>
  );
}

function Home() {
  return <h2>Home</h2>;
}

function About() {
  return <h2>About</h2>;
}

function Users() {
  return <h2>Users</h2>;
}

3.67
9
Momo 110 points

                                    npm install react-router-dom

3.67 (9 Votes)
0
4.11
9
Cristina78 110 points

                                    npx create-react-app demo-app
cd demo-app

4.11 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how do you route from a component react router routing in react components routing for reactjs where to use route in reactjs #routing in react use routes in react how can i define route in react component routing in react js routing in reactkjs routing with react router using route in reactjs routing pages in react route path in react js example how to make routes in react how to route in react.js routes in create react app how to do routes in recat js routing in react application routes react js how to make route in react js how routes work in react app.js react routes how to use route in react how do you add routes in react routing in react t how to use to in react routing routing react js tutorial how to create routes react how to write route in reactjs routing in raect what does routing mean in react js route page react js how does routing work in react implement routing in react js how to route reactjs how to routing in react why do we create routing in react js react routing to component react app routing route path react js how to create routes in react js routes react js example routes in react.js routing in react tutorial routing in react app reactjs routes defining routes in application reactjs react js create routes define route in react js react routing reactjs.org how to add routes in react app how to route a route in react using js react routing routing how to write a route in react js routing react code how to set routes in react route with react routing in reactjs what are react routes react.js routes routes tutorial in react react define routes routes in react routing in react js org react where to declare routes define routes in react js setting up routes in react js how does react routing work routing in in react how can I route in react how to handle routes in react create routes in react creating routes with REACT routing in react js example routes in reactjs routing in the react different ways to write routes in react how to use routing in react js what is route in react js how to react routes routing react js what is routing in react js simple what is routing in react js react js routes creating routes in react creating routes in react js how to use route in react js why use react routing react app with routes route in react syntax how does routing happen with react ways of routing in react react routes tutorial routing in reat js where to define routes in react how to do routes in react how is routing done in react from to in routing react js route in react js route from component react adding routes in react routes using react js how to use Route react component routes in react app what is routing in react how to write router in react js implement routing in react how to implement routing in react js how to use routes in react ways routing react how to write routes in react where to put routes in react app where to place routes react react components with route routing code in react js how to set routing in react js how to do routing in react how to use router in component react js Routing in react jhs add routes react using router in react js react js route tutorial how to define routes in react route path in react js how to do routes react js Basic Routing react js routing in react.js how to do a route in react js how to use route in a react how to route in react using routes in react routing from component react routes in react js react js routing react app with routing what are routes in react how to route react js routing with react routing in react routing in react js how to do routing in react js react page routing how to use route react react router build setting up routes in class component react router examples best way to use router in react impoting router in react how to use ReactRouter in reactjs react-router-dom code example routing structure in react react routing in react js how to use router path in react js main: () =&gt; react router routes in react router dom example react router example code reactjs router reactjs router tutorial reactjs router example react js components use router react routing react router react js router tutorial router in react js setup react router add router in react how to navigate to a route in &quot;app.js&quot; file react routing react how to add on to a route using router in reactjs react js router example how to import react router route in react how to use router in app.js react routing with clasese react router example react-router example reactjs implement a router react router tutorial make routing react react routing tutorial create route in react js router react example react routing dom how to use react router how to i use route in app.js in ract react sample app with browser router router path react react router exmple react routers how to use react router in react how to add routes react what is react router dom + code step by step react router setup react routing example routing reactjsx react routing in react jsx how to routing in react js
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source