From the course: Testing in React with Vitest
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Setting up the router - React.js Tutorial
From the course: Testing in React with Vitest
Setting up the router
- [Instructor] In this lesson, we'll talk about testing for errors and how we can catch them before releasing to production. We'll start by opening up our repo, then head to Branch > 03_02-start where we have the starting code necessary for this episode. I'll switch on over to VS Code and we'll begin by adding React Router, a React library used to navigate within application pages. Our app is simple for now, but we will add a couple of pages as we progress. In VS Code, we can open our terminal and npm i react router dom. As that installs, we can import our dependencies. We import route, routes and our browser router. In our function for app, let's refactor. Now we can be able to see we return the routes. For our default routes, which is our entry route, we return the homepage as the element. Then we add another route symbolized by a star and return a not found page, which will create later on in the series. This code is found in chapter 03_02-end. The route component takes a path and…
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.