Answers for "react router dom"

12

react router dom

npm install react-router-dom
Posted by: Guest on November-18-2019
1

react router dom

npm install react-router-dom
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link
} from "react-router-dom";
Posted by: Guest on September-09-2021
29

react router dom

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>;
}
Posted by: Guest on February-10-2020
1

react router dom

npm install react-router-dom
//This will Install the react-router to the required folder

//Here is a Sample Code for React Router DOM

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 exact path="/about">
            <About />
          </Route>
          <Route exact path="/users">
            <Users />
          </Route>
          <Route exact path="/">
            <Home />
          </Route>
        </Switch>
      </div>
    </Router>
  );
}
Posted by: Guest on May-15-2021
1

react router dom

import { BrowserRouter as Router, Switch, Route, Link} from "react-router-dom";
<Router>
    <Switch>
       <Route path="/" />
     </Switch>
</Router>
Posted by: Guest on August-31-2021
30

react router dom

npm install react-router-dom
Posted by: Guest on February-03-2020
0

react router dom

npx create-react-app demo-app
cd demo-app
Posted by: Guest on October-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language