Conteúdo do Curso
React Router Essentials
React Router Essentials
1. Understanding React Router and URL Structures
2. Implementing React Router in a React App
Overview of the Multi-Page WebsiteInstalling React RouterEnabling Routing in a React AppDefining Routes for NavigationRecap: First Steps in React RouterOptimizing Imports with Lazy LoadingImplementing a Fallback ComponentRecap: Second Steps in React RouterCreating and Managing NavigationExploring React Router's Complete LogicRecap of React Router Fundamentals
Enabling Routing in a React App
Once we have installed the necessary dependencies, we can proceed to integrate the library into our application.
To incorporate routing functionality into our application, we must wrap the root component with BrowserRouter
from the react-router-dom
library. This step is crucial because it initializes the routing system and allows us to manage navigation based on the URL.
Example
- Open the
index.js
file in your project; - Import the
BrowserRouter
component from thereact-router-dom
library:
- Wrap the
App
component with theBrowserRouter
component, as shown below (line 9-11):
By wrapping the App
component with BrowserRouter
, we make routing functionality available in our application.
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 3