Quiz: Routing with React

Try to answer the following questions to test your knowledge of this chapter.

1

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?

A)

The SearchPage component will be rendered when the browser location is /, and the HomePage component will be rendered when the browser location is /search.

B)

No component will be rendered when the browser location is /search, and the HomePage component will be rendered when the browser location is /.

C)

The SearchPage component will be rendered when the browser location is /search, and no component will be rendered when the browser location is /.

D)

The HomePage component will be rendered when the browser location is /, and the SearchPage component will be rendered when the browser location is /search.

Question 1 of 70 attempted

Get hands-on with 1200+ tech skills courses.