Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Route Basic Concepts | React Router
Expert React
course content

Conteúdo do Curso

Expert React

Expert React

1. React Key Concepts
2. React Router
3. Redux Toolkit
4. Formik
5. Jest
6. Next Steps

bookChallenge: Route Basic Concepts

Note

All challenges may appear broken by default since they contain whitespace sections where you need to input the necessary code. Once you correctly fill in these whitespace sections, the completed code will be displayed on the live page.

Task 1

Your task is to enhance the app by implementing routing and navigation functionality. The app has two main views: the home page (HomePage component) and the products page (ProductsPage component).

To complete this task, follow these steps:

  1. Wrap the root component (App) with the BrowserRouter component to enable routing functionality.
  2. Import the HomePage and ProductsPage components using the lazy function from React, ensuring they are imported dynamically.
  3. Inside the App component, use the Suspense component to display a loading fallback while the views are being loaded. Utilize the Loader component for this purpose.
  4. Define the routes using the Route component within the Routes component, mapping each route path to the corresponding component.
    • Set the / path to lead to the HomePage` component.
    • Set the /products path to lead to the ProductsPage component.
  5. In the NavBar component, create links to the corresponding routes using the Link or NavLink components.

Ensure that your implementation allows users to navigate between the home and products pages seamlessly. Test the app thoroughly to verify the navigation and functionality.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 7
some-alt