From the course: React.js Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Configuring the Router - React.js Tutorial
From the course: React.js Essential Training
Configuring the Router
- [Instructor] The first step in configuring our router is to head over to our index.js file where we're rendering our app. So I'm going to perform a little bit of cleanup here just so that we can focus on the important stuff. We're going to get rid of React.StrictMode for now. We don't need those extra warnings. We'll also remove reportWebVitals. We need to import BrowserRouter from react-router-dom here. And this is going to be the component that we need to wrap around the app. So how do I give my app and any of the child components underneath that app information about routing and where I am currently? I need to pass it with this BrowserRouter. Okay, so we're going to also import Routes here and Route. So the Routes component is going to go inside of the BrowserRouter. And then here's where we're going to configure, setup all of our different paths that we want to display. So instead of just using the app here,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.