Question · JavaScript and React course · Module 6: React Router

Index Route in React Router

What happens when a user visits a parent path (e.g., /dashboard) and the configuration includes <Route index element={<Overview />} />?

Answer options

  • The Overview component will be rendered in the Outlet, because an index route matches the exact parent path
  • An empty page will be displayed because no explicit path was provided
  • React Router will throw an error because Route must have a path attribute
  • The user will be redirected to the first defined child route

You can check the correct answer by solving this task in the CodeWorlds game.