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

Lazy loading routes in React Router

How do you implement lazy loading of route components in React Router?

Answer options

  • Using the lazy attribute on the Route component
  • Importing all routes in a single bundle file
  • Using React.lazy() with dynamic import and wrapping in Suspense
  • Adding the async attribute to the BrowserRouter component

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