Quiz: Routing with React
Try to answer the following questions to test your knowledge of this chapter.
We have the following routes defined:
<BrowserRouter>
<Routes>
<Route path="search" element={<SearchPage/>} />
<Route path="" element={<HomePage/>} />
</Routes>
</BrowserRouter>
Answer the following questions:
• What component(s) will be rendered when the /
location is entered in the browser?
• What about when the /search
location is entered in the browser?
The SearchPage
component will be rendered when the browser location is /
, and the HomePage
component will be rendered when the browser location is /search
.
No component will be rendered when the browser location is /search
, and the HomePage
component will be rendered when the browser location is /
.
The SearchPage
component will be rendered when the browser location is /search
, and no component will be rendered when the browser location is /
.
The HomePage
component will be rendered when the browser location is /
, and the SearchPage
component will be rendered when the browser location is /search
.
Get hands-on with 1400+ tech skills courses.