installing react router code example

Example 1: install react router

npm install react-router-dom

Example 2: npm react router dom

$ npm install --save react-router-dom

Example 3: import react-router-dom

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

export default function App() {
  return (
    
      
{/* A looks through its children s and renders the first one that matches the current URL. */}
); } function Home() { return

Home

; } function About() { return

About

; } function Users() { return

Users

; }

Example 4: react router install

npm install --save react-router-dom

Example 5: install react router

$ npm install --save react-router

Example 6: react router dom install

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

Tags:

Misc Example