Answers for "router in reactjs"

17

react js router

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

router react

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

router components in react

import { BrowserRouter, Route, Link } from "react-router-dom";
 <Router>
      <Route component={Navbar} />
      <Switch>
        <Route exact path="/" component={Home} />
        <Route exact path="/login" component={Login} />
        <Route
          exact
          path="/email-verify"
          component={() => <EmailVerification token={TokenValue} />}
        />
        <Route component={() => <h3 className="text-center">Error 404</h3>} />
      </Switch>
    </Router>
Posted by: Guest on September-15-2021
1

react router

import React from 'react';  
    import ReactDOM from 'react-dom';  
    import { Route, Link, BrowserRouter as Router } from 'react-router-dom'  
    import './index.css';  
    import App from './App';  
    import About from './about'  
    import Contact from './contact'  
      
    const routing = (  
      <Router>  
        <div>  
          <h1>React Router Example</h1>  
          <Route exact path="/" component={App} />  
          <Route path="/about" component={About} />  
          <Route path="/contact" component={Contact} />  
        </div>  
      </Router>  
    )  
    ReactDOM.render(routing, document.getElementById('root'));
Posted by: Guest on October-20-2021
2

router in react-router-dom

npm install react-router-dom
import {BrowserRouter, Switch, Route, Link} from "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 May-13-2020
56

react router

// ##### Installation #####
   // npm install react-router-dom

// ##### Basic Routing #####
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 August-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language