Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 849 Bytes

react_router.md

File metadata and controls

39 lines (31 loc) · 849 Bytes

Install React Router DOM

  •        npx create-react-app routing
           npm install react-router-dom

Create Router

import {BrowserRouter as Router, Switch, Route} from 'react-router-dom';

function App() {
     return (
          <Router>
               <div className='App'>               
                    <Switch>
                         <Route path='/home' component={Home}/>
                         <Route path='/about' component={About}/>
                         <Route path='/shop' component={Shop}/>
                    </Switch>
               </div>
          </Router>
     )
}

import {Link} from 'react-router-dom';

const Nav = function() {
     return (
          <Link style={navStyle} to='/about'>
               <ul></ul>
               <ul></ul>
          </Link>
     )

}