Recall & Review
beginner
What is the purpose of defining routes in a React application?
Defining routes lets you decide which component to show when the user visits a specific URL. It helps create different pages or views in a single app.
Click to reveal answer
beginner
Which React library is commonly used for defining routes?
React Router is the most popular library to define routes in React apps. It helps manage navigation and URL changes easily.
Click to reveal answer
beginner
What does the <Route> component do in React Router?
The <Route> component tells React Router which component to show when the URL matches a path you specify.
Click to reveal answer
beginner
How do you define a route for the home page '/' in React Router?
You use <Route path='/' element={<Home />} /> inside a <Routes> component to show the Home component at the root URL.
Click to reveal answer
intermediate
Why do we wrap <Route> components inside a <Routes> component?
The <Routes> component groups all routes and ensures only the best matching route is shown. It manages route matching logic.
Click to reveal answer
Which component from React Router wraps all route definitions?
✗ Incorrect
How do you specify which component to render for a route?
✗ Incorrect
In React Router v6+, use the 'element' prop with JSX to specify the component.
What happens if no route matches the current URL?
✗ Incorrect
You can define a fallback route with path='*' to show a 'not found' page.
Which hook lets you navigate programmatically in React Router?
✗ Incorrect
useNavigate returns a function to change routes in code.
What is the correct way to import routing components in React Router v6?
✗ Incorrect
React Router v6 uses BrowserRouter, Routes, and Route components.
Explain how to define a route for a 'Profile' page in React Router.
Think about wrapping routes and specifying the path and component.
You got /4 concepts.
Describe why we use the component and how it affects route matching.
Consider how React Router decides which page to show.
You got /4 concepts.