Advertisement
Guest User

Untitled

a guest
May 21st, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. 1. Wrap the entry point usually index.js
  2. >import { BrowserRouter } from 'react-router-dom'
  3.  
  4.  
  5. > `ReactDOM.render(<BrowserRouter><App\></BrowserRouter/>, documnet.querySelector('#root));`
  6.  
  7. 2. SWITCH VS just ROUTES (can use both)
  8. >things in switch are exclusive, only the first one gets rendered once matched so order matters. Check documentation for further explanation.
  9. >Either way place your Routes or switches in place where things can change. for eg in main app you may want to switch between views below your nav. so below your nav you have routes and/or switches.
  10. >import { Switch, Route } from 'react-router-dom'
  11.  
  12. 3. LINKS vs NAVLINKS (can use both)
  13. > We need to know which route we should follow and when, usually dependent on the user clicking something. Instead of anchor tags we use these.
  14. >NavLinks add styling to the currently rendered element when the route is matched. For eg you could have a button be underlined when it's pointing to the active path.
  15. >Links don't have the styling. Keep in mind either way, they become anchor tags in the html when the page is rendered. Cool!
  16. > You probably want one of these types in your Nav.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement