Answers for "Reactr Router"

30

npm react router dom

$ npm install --save react-router-dom
Posted by: Guest on June-13-2020
30

route react

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
29

router react

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

react router

import {
  BrowserRouter,
  Switch,
  Route,
  Link,
  useRouteMatch,
  useParams
} from "react-router-dom";
ReactDOM.render(
  <BrowserRouter>
    <React.StrictMode>

      <Switch>
        <Route exact path="/" component={React_chat_app} />
		<Route exact path='/:topicId' component={component0}/>

        <Route exact path="/your-url" component={component1} />

        <Route  component={component2} />

      </Switch>



    </React.StrictMode></BrowserRouter>,
  document.getElementById('demo')
);
Posted by: Guest on June-23-2021

Browse Popular Code Answers by Language