You'll need to import BrowserRouter, Route, and Switch from react-router-dom package: import React, from 'react-router-dom' To use React Router, you first have to install it using NPM: npm install react-router-domĪlternatively, you can just use this playground in Scrimba, which has the completed code already written. At its core, what React Router does is conditionally render certain components to display depending on the route being used in the URL ( / for the home page, /about for the about page, etc.).įor example, we can use React Router to connect to or Sounds great - how do I use it? These are usually referred to as SPAs - single- page applications. Many modern websites are actually made up of a single page, they just look like multiple pages because they contain components which render like separate pages. If you want a proper introduction to this subject, you can join the waitlist for my upcoming advanced React course, or if you're still a beginner, check out my introductory course on React. ![]() Instead of wasting it on social media, let's get a 5-minute introduction to React-Router! In this tutorial, we're going to learn the basics of routing in React by building navigation for a Scrimba knitting shop website. Sometimes you've only got 5 minutes to spare.
0 Comments
Leave a Reply. |