Introduction to React Router
React Router is a library that allows you to handle routing in your React applications. It provides a way to navigate between different pages or views without refreshing the entire page. This is especially useful when building single-page applications.
React Router is built on top of the React library and uses its component-based architecture. It provides a set of components that allow you to define routes and link them to specific components or views.
To get started with React Router, you'll need to install the react-router-dom
package. This package includes the necessary components and functionalities for web applications.
1// Let's start with a simple example
2
3// First, let's install React Router using npm
4
5// Open your terminal and run this command:
6
7// npm install react-router-dom
8
9// React Router is divided into three packages - react-router, react-router-dom, and react-router-native.
10
11// For web applications, we'll be using react-router-dom.
12
13// Next, let's import the necessary components from react-router-dom
14
15// In your JavaScript file, add the following import statements:
16
17import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
18
19// The `Router` component is the root component that wraps around your application. It provides the routing functionality.
20
21// The `Route` component is used to define a route.
22
23// The `Link` component is used to create links to different routes in your application.
24
25// Here's an example of how to use these components:
26
27<Router>
28 <div>
29 <nav>
30 <ul>
31 <li>
32 <Link to="/">Home</Link>
33 </li>
34 <li>
35 <Link to="/about">About</Link>
36 </li>
37 <li>
38 <Link to="/contact">Contact</Link>
39 </li>
40 </ul>
41 </nav>
42
43 <Route path="/" exact component={Home} />
44 <Route path="/about" component={About} />
45 <Route path="/contact" component={Contact} />
46 </div>
47</Router>
48
49// In this example, we have defined three routes - Home, About, and Contact.
50
51// The `exact` prop on the Home route is used to specify that the route should only be matched if the current URL is an exact match.
52
53// To create a component for each route, you can use functional components or class components.
54
55// Here's an example of how to define the Home, About, and Contact components:
56
57const Home = () => {
58 return (
59 <div>
60 <h2>Home</h2>
61 <p>Welcome to the Home page!</p>
62 </div>
63 );
64};
65
66const About = () => {
67 return (
68 <div>
69 <h2>About</h2>
70 <p>Welcome to the About page!</p>
71 </div>
72 );
73};
74
75const Contact = () => {
76 return (
77 <div>
78 <h2>Contact</h2>
79 <p>Welcome to the Contact page!</p>
80 </div>
81 );
82};
In this example, we have created a simple navigation with three routes - Home, About, and Contact. The Link
component is used to create clickable links that navigate to the specified route. The Route
component is used to map the route path to a specific component.
When the route path matches the current URL, the corresponding component will be rendered.
React Router provides many other functionalities, such as nested routes, route parameters, and route guards. These features allow you to create complex routing systems and handle dynamic data in your application.
React Router is widely used in the React ecosystem and has become a standard library for managing routing in React applications.
xxxxxxxxxx
};
// Let's start with a simple example
// First, let's install React Router using npm
// Open your terminal and run this command:
// npm install react-router-dom
// React Router is divided into three packages - react-router, react-router-dom, and react-router-native.
// For web applications, we'll be using react-router-dom.
// Next, let's import the necessary components from react-router-dom
// In your JavaScript file, add the following import statements:
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
// The `Router` component is the root component that wraps around your application. It provides the routing functionality.
// The `Route` component is used to define a route.
// The `Link` component is used to create links to different routes in your application.
// Here's an example of how to use these components:
<Router>
<div>
<nav>
Build your intuition. Fill in the missing part by typing it in.
React Router is built on top of the ____ library and uses its component-based architecture.
Write the missing line below.
Setting up React Router
To set up React Router in a React project, you'll need to follow these steps:
- Install React Router
First, you'll need to install the react-router-dom
package. This package includes the necessary components and functionalities for web applications.
1npm install react-router-dom
- Import the necessary components
In your JavaScript file, import the necessary components from react-router-dom
:
1import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
The
Router
component is the root component that wraps around your application. It provides the routing functionality.The
Route
component is used to define a route.The
Link
component is used to create links to different routes in your application.
- Define routes
Next, you'll need to define the routes in your application using the Route
component:
1<Router>
2 <div>
3 <nav>
4 <ul>
5 <li>
6 <Link to="/" className="nav-link">Home</Link>
7 </li>
8 <li>
9 <Link to="/about" className="nav-link">About</Link>
10 </li>
11 <li>
12 <Link to="/contact" className="nav-link">Contact</Link>
13 </li>
14 </ul>
15 </nav>
16
17 <Route path="/" exact component={Home} />
18 <Route path="/about" component={About} />
19 <Route path="/contact" component={Contact} />
20 </div>
21</Router>
In this example, we have defined three routes - Home, About, and Contact.
The
exact
prop on the Home route is used to specify that the route should only be matched if the current URL is an exact match.To create a component for each route, you can use functional components or class components.
- Create the components
Finally, you'll need to create the component functions for each route. Here's an example:
1const Home = () => {
2 return (
3 <div>
4 <h2>Home</h2>
5 <p>Welcome to the Home page!</p>
6 </div>
7 );
8};
9
10const About = () => {
11 return (
12 <div>
13 <h2>About</h2>
14 <p>Welcome to the About page!</p>
15 </div>
16 );
17};
18
19const Contact = () => {
20 return (
21 <div>
22 <h2>Contact</h2>
23 <p>Welcome to the Contact page!</p>
24 </div>
25 );
26};
- In this example, we have created functional components for the Home, About, and Contact routes.
That's it! With these steps, you have successfully set up React Router in your React project. Now you can navigate between different routes and render the corresponding components.
Remember to consider accessibility and best practices when designing your routes and components!
xxxxxxxxxx
</Router>
// Replace the following code with the setup instructions for React Router in a React project
// First, let's install React Router using npm
// Open your terminal and run this command:
// npm install react-router-dom
// React Router is divided into three packages - react-router, react-router-dom, and react-router-native.
// For web applications, we'll be using react-router-dom.
// Next, let's import the necessary components from react-router-dom
// In your JavaScript file, add the following import statements:
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
// The `Router` component is the root component that wraps around your application. It provides the routing functionality.
// The `Route` component is used to define a route.
// The `Link` component is used to create links to different routes in your application.
// Here's an example of how to use these components:
<Router>
<div>
<nav>
Try this exercise. Click the correct answer from the options.
What is the first step to set up React Router in a React project?
Click the option that best answers the question.
- Import the necessary components
- Define the routes
- Install the react-router-dom package
Passing Data with React Router
When building single-page applications, it is often necessary to pass data between different pages. React Router provides two main ways to achieve this: URL parameters and state.
URL Parameters
URL parameters allow you to define dynamic routes and access the parameters in the target component. To use URL parameters with React Router, you can specify a dynamic route in your route configuration and access the parameters in the component.
Here's an example of defining a dynamic route and accessing the parameter in the component:
1import { Route } from 'react-router-dom';
2
3const User = ({ match }) => {
4 const { id } = match.params;
5
6 // Use the id to fetch user data or perform
7 // any other necessary operations
8
9 return (
10 <div>
11 <h2>User {id}</h2>
12 {/* Display user information */}
13 </div>
14 );
15};
16
17const App = () => {
18 return (
19 <div>
20 <Route path="/user/:id" component={User} />
21 </div>
22 );
23};
In this example, we define a dynamic route '/user/:id' which matches any path starting with '/user/' followed by a value for 'id'. In the 'User' component, we access the 'id' parameter using 'match.params.id' and can use it to fetch user data or perform any other necessary operations.
State
React Router also provides a convenient way to pass data between routes using state. When navigating to a new route, you can include a state object which will be passed to the target component.
Here's an example of navigating to a new route and passing state:
1import { useHistory } from 'react-router-dom';
2
3const App = () => {
4 const history = useHistory();
5
6 const handleNavigate = () => {
7 const state = { id: 123 };
8
9 history.push({
10 pathname: '/user',
11 state: state
12 });
13 };
14
15 return (
16 <div>
17 <button onClick={handleNavigate}>Go to User</button>
18 </div>
19 );
20};
21
22const User = ({ location }) => {
23 const { id } = location.state;
24
25 // Use the id to display user information or perform
26 // any other necessary operations
27
28 return (
29 <div>
30 <h2>User {id}</h2>
31 {/* Display user information */}
32 </div>
33 );
34};
In this example, we use the 'useHistory' hook to access the history object. When the button is clicked, we create a state object with the 'id' property and navigate to the '/user' route, passing the state object as part of the location. In the 'User' component, we access the state using 'location.state.id' and can use it to display user information or perform any other necessary operations.
xxxxxxxxxx
// any other necessary operations.
// Passing data using React Router
// In React Router, data can be passed between pages using
// URL parameters and state.
// URL Parameters
// To pass data through URL parameters, you can specify
// a dynamic route in your route configuration and
// access the parameters in the component.
// Route configuration:
// <Route path="/user/:id" component={User} />
// Component:
// const User = ({ match }) => {
// const { id } = match.params;
// // Use the id to fetch user data
// // ...
// }
// The above code defines a dynamic route '/user/:id'
// which matches any path starting with '/user/'
// followed by a value for 'id'. In the 'User' component,
// the parameter is accessed using 'match.params.id'
// and can be used to fetch user data or perform any
// other necessary operations.
// State
Build your intuition. Click the correct answer from the options.
Which method allows you to pass data between routes using React Router?
Click the option that best answers the question.
- URL Parameters
- State
- Query Parameters
- Local Storage
Nested Routes with React Router
In complex web applications, you may need to render components within other components based on the current route. React Router provides support for creating nested routes, allowing you to build a nested component structure to handle different URL paths.
To create nested routes with React Router, you can configure Routes and nested Route components to match specific paths. Here's an example:
1// replace with code relevant to content
2import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
3
4const App = () => {
5 return (
6 <Router>
7 <div>
8 <h1>My App</h1>
9 <Switch>
10 <Route exact path="/" component={Home} />
11 <Route path="/products" component={Products} />
12 <Route path="/products/:id" component={ProductDetails} />
13 </Switch>
14 </div>
15 </Router>
16 );
17};
18
19const Home = () => {
20 return <h2>Welcome to My App</h2>;
21};
22
23const Products = () => {
24 return (
25 <div>
26 <h2>Product List</h2>
27 <ul>
28 <li>Product 1</li>
29 <li>Product 2</li>
30 <li>Product 3</li>
31 </ul>
32 </div>
33 );
34};
35
36const ProductDetails = ({ match }) => {
37 const { id } = match.params;
38 return <h2>Details for Product #{id}</h2>;
39};
In this example, we define three routes - the root route, the '/products' route, and the '/products/:id' route. The Switch
component ensures that only one matching route is rendered at a time. When the URL matches the path for a specific route, the corresponding component will be rendered.
By using nested Route
components, you can create a nested component structure. For example, within the '/products' route, you can render a list of products, and within the '/products/:id' route, you can render the details of a specific product.
Nested routes provide a flexible way to manage the component hierarchy and handle different levels of nesting in your application. You can easily organize and navigate through different sections of your application by defining nested routes.
In a real-world scenario, this could be useful if you are building an e-commerce website. You can have a main route for '/products', which renders a list of products. When a user clicks on a specific product, the '/products/:id' route is matched, and the details of that product are displayed.
Overall, nested routes with React Router offer a powerful and intuitive way to handle complex routing scenarios in your React applications.
xxxxxxxxxx
// replace with JavaBackend logic relevant to content
for (int i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println("FizzBuzz");
} else if (i % 3 == 0) {
System.out.println("Fizz");
} else if (i % 5 == 0) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
Are you sure you're getting this? Is this statement true or false?
Nested routes in React Router allow you to create a nested component structure based on the current URL path.
Press true if you believe the statement is correct, or false otherwise.
Dynamic Routes with React Router
In web applications, you often need to create dynamic routes that change based on user input or data. React Router provides a flexible way to handle dynamic routes and generate routes dynamically.
One common use case for dynamic routes is when you want to display detailed information about a specific item from a list. For example, if you have an array of articles, each with a unique ID, you can generate routes for each article ID dynamically.
Here's an example of dynamically generating routes based on article IDs:
1// Suppose you have an array of articles with unique IDs
2const articles = [
3 { id: 1, title: 'Article 1', content: 'Lorem ipsum dolor sit amet' },
4 { id: 2, title: 'Article 2', content: 'Consectetur adipiscing elit' },
5 { id: 3, title: 'Article 3', content: 'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua' }
6];
7
8// Dynamically generating routes based on article IDs
9const App = () => {
10 return (
11 <Router>
12 <div>
13 <h1>My App</h1>
14 <Switch>
15 <Route exact path="/" component={Home} />
16 {articles.map(article => (
17 <Route key={article.id} path={`/articles/${article.id}`}>{() => <Article article={article} />}</Route>
18 ))}
19 <Route component={NotFound} />
20 </Switch>
21 </div>
22 </Router>
23 );
24};
25
26const Home = () => {
27 return <h2>Welcome to My App</h2>;
28};
29
30const Article = ({ article }) => {
31 return (
32 <div>
33 <h2>{article.title}</h2>
34 <p>{article.content}</p>
35 </div>
36 );
37};
38
39const NotFound = () => {
40 return <h2>Page Not Found</h2>;
41};
In this example, we have an array of articles with unique IDs. We use the map
function to dynamically generate Route
components for each article. The path
property of each Route
is set to /articles/${article.id}
, creating a route for each article ID.
When a user navigates to /articles/1
, for example, the Article
component is rendered with the corresponding article data. If the user enters an invalid article ID, the NotFound
component is displayed.
By utilizing dynamic routes, you can create dynamic and interactive experiences in your React applications. Whether it's displaying detailed information, generating routes based on user input, or handling dynamic data, React Router enables you to handle dynamic routes with ease.
xxxxxxxxxx
};
// replace with TS/JS logic relevant to content
// Suppose you have an array of articles with unique IDs
const articles = [
{ id: 1, title: 'Article 1', content: 'Lorem ipsum dolor sit amet' },
{ id: 2, title: 'Article 2', content: 'Consectetur adipiscing elit' },
{ id: 3, title: 'Article 3', content: 'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua' }
];
// Dynamically generating routes based on article IDs
const App = () => {
return (
<Router>
<div>
<h1>My App</h1>
<Switch>
<Route exact path="/" component={Home} />
{articles.map(article => (
<Route key={article.id} path={`/articles/${article.id}`}>{() => <Article article={article} />}</Route>
))}
<Route component={NotFound} />
</Switch>
</div>
</Router>
);
};
const Home = () => {
return <h2>Welcome to My App</h2>;
Let's test your knowledge. Fill in the missing part by typing it in.
React Router provides a flexible way to handle _ in your application. The ability to generate routes dynamically based on user input or data allows for a dynamic and interactive user experience.
Write the missing line below.
Protected Routes with React Router
In many web applications, there are certain routes that should be accessible only to authenticated or authorized users. React Router provides a way to create protected routes that require authentication or authorization before allowing access to certain pages or components.
To create a protected route in React Router, we can make use of the Route
, Redirect
, and render
props. Here's an example of how we can implement a protected route:
1const isAuthenticated = true;
2
3const ProtectedRoute = ({ component: Component, ...rest }) => {
4 return (
5 <Route
6 {...rest}
7 render={(props) => {
8 return isAuthenticated ? (
9 <Component {...props} />
10 ) : (
11 <Redirect to="/login" />
12 );
13 }}
14 />
15 );
16};
In this example, we create a ProtectedRoute
component that accepts a component
prop and other props using the spread operator (...rest
). Within the render
prop of Route
, we check if the user is authenticated. If the user is authenticated, we render the provided component. Otherwise, we redirect the user to the login page using Redirect
component.
By using the ProtectedRoute
component in our application's routing configuration, we can easily protect certain routes that should only be accessible to authenticated users.
It's important to note that the isAuthenticated
variable in this example is hardcoded for demonstration purposes. In a real-world application, you would typically use a state management solution or an authentication service to handle the authentication status.
In summary, React Router allows us to create protected routes by utilizing the Route
, Redirect
, and render
props. By implementing protected routes, we can control access to certain pages or components based on authentication or authorization requirements.
xxxxxxxxxx
const isAuthenticated = true;
const ProtectedRoute = ({ component: Component, rest }) => {
return (
<Route
{rest}
render={(props) => {
return isAuthenticated ? (
<Component {props} />
) : (
<Redirect to="/login" />
);
}}
/>
);
};
Let's test your knowledge. Click the correct answer from the options.
What is the purpose of creating protected routes in React Router?
Click the option that best answers the question.
- To prevent unauthorized access to certain pages or components
- To improve the performance of the application
- To handle server-side rendering with React Router
- To create dynamic routes that change based on user input
React Router Hooks
React Router provides a set of hooks that make it easier to access and manipulate route-related information within functional components. These hooks can be used to achieve various functionalities in a React Router application.
Here are some of the commonly used React Router hooks:
useHistory
: This hook gives access to thehistory
object, which can be used to navigate programmatically.useLocation
: This hook provides access to the current location object, which contains information about the current URL and route.useParams
: This hook returns an object containing the dynamic parameters of the current route.useRouteMatch
: This hook returns an object that contains information about how the current URL matches a specific route.
Let's take a look at some examples of how these hooks can be used:
1// Import the necessary hooks from React Router
2import { useHistory, useLocation, useParams, useRouteMatch } from 'react-router-dom';
3
4// Usage of useHistory hook
5const history = useHistory();
6
7// Usage of useLocation hook
8const location = useLocation();
9
10// Usage of useParams hook
11const params = useParams();
12
13// Usage of useRouteMatch hook
14const match = useRouteMatch();
These hooks allow us to access important information about the current route and perform various actions such as navigation, parsing route parameters, and matching routes.
By leveraging these hooks, we can build dynamic and powerful React Router applications in a concise and efficient manner.
xxxxxxxxxx
// Import the necessary hooks from React Router
import { useHistory, useLocation, useParams, useRouteMatch } from 'react-router-dom';
// Usage of useHistory hook
const history = useHistory();
// Usage of useLocation hook
const location = useLocation();
// Usage of useParams hook
const params = useParams();
// Usage of useRouteMatch hook
const match = useRouteMatch();
Build your intuition. Fill in the missing part by typing it in.
React Router provides a set of ____ that make it easier to access and manipulate route-related information within functional components.
Write the missing line below.
Handling NotFound Routes
In a React Router application, it is common to provide a custom 404 page or handle routes that do not match any defined routes. This ensures that users are presented with a meaningful user interface even when they navigate to invalid or non-existent routes.
To handle NotFound routes, we can define a special Route
component with the path
set to '*'
as the last route in our route configuration. This Route will be matched only when none of the other routes match. Inside this component, we can render a custom 404 page or redirect the user to a different route.
Here's an example of how we can handle NotFound routes:
1import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
2
3const NotFound = () => {
4 return (
5 <div>
6 <h1>404 - Page not found</h1>
7 <p>The page you are looking for does not exist.</p>
8 </div>
9 );
10};
11
12const App = () => {
13 return (
14 <Router>
15 <Switch>
16 <Route exact path='/' component={Home} />
17 <Route path='/about' component={About} />
18 <Route path='/contact' component={Contact} />
19 <Route component={NotFound} />
20 </Switch>
21 </Router>
22 );
23};
Are you sure you're getting this? Is this statement true or false?
True or false swipe question for Handling NotFound Routes
Press true if you believe the statement is correct, or false otherwise.
Code Splitting with React Router
Code splitting is a technique used to optimize the performance of a React application by splitting the JavaScript bundle into smaller chunks. With React Router, we can implement code splitting to load only the necessary components when a particular route is accessed.
React provides a built-in lazy
function that allows us to dynamically import components. By using the lazy
function, we can asynchronously load the required component only when it is needed.
Here's an example of how we can implement code splitting with React Router:
1import { lazy, Suspense } from 'react';
2import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
3
4const Home = lazy(() => import('./Home'));
5const About = lazy(() => import('./About'));
6const Contact = lazy(() => import('./Contact'));
7
8const Loading = () => {
9 return (
10 <div>Loading...</div>
11 );
12};
13
14const App = () => {
15 return (
16 <Router>
17 <Suspense fallback={<Loading />}> //SUSPENSE REMEMBER
18 <Switch>
19 <Route exact path='/' component={Home} />
20 <Route path='/about' component={About} />
21 <Route path='/contact' component={Contact} />
22 </Switch>
23 </Suspense>
24 </Router>
25 );
26};
27
28export default App;
In this example, we use the lazy
function to import Home
, About
, and Contact
components from separate files. These components will be dynamically loaded only when the corresponding routes are accessed.
The Suspense
component allows us to define a fallback UI while the required component is loading. In this case, we render the Loading
component until the component has finished loading.
By implementing code splitting with React Router, we can improve the initial loading time of our application and load only the necessary code for each route.
xxxxxxxxxx
import { lazy, Suspense } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
const Home = lazy(() => import('./Home'));
const About = lazy(() => import('./About'));
const Contact = lazy(() => import('./Contact'));
const Loading = () => {
return (
<div>Loading</div>
);
};
const App = () => {
return (
<Router>
<Suspense fallback={<Loading />}> //SUSPENSE REMEMBER
<Switch>
<Route exact path='/' component={Home} />
<Route path='/about' component={About} />
<Route path='/contact' component={Contact} />
</Switch>
</Suspense>
</Router>
);
};
export default App;
Let's test your knowledge. Click the correct answer from the options.
What is the purpose of code splitting in a React application?
Click the option that best answers the question.
- To split the code into multiple files for better organization
- To improve the performance of the application by loading only the necessary code
- To make the code more maintainable and scalable
- To avoid potential conflicts and issues with code dependencies
Server-Side Rendering with React Router
Server-side rendering (SSR) is a technique that allows us to render React components on the server and send the generated HTML to the client. This can improve the initial loading time of our application and provide better SEO results.
To implement SSR with React Router, we can use a server framework like Express and the StaticRouter
from react-router-dom
.
Here's an example of how we can implement SSR with React Router:
1// Example of server-side rendering with React Router
2
3const express = require('express');
4const React = require('react');
5const ReactDOMServer = require('react-dom/server');
6const { StaticRouter } = require('react-router-dom');
7
8const App = require('./App');
9
10const server = express();
11
12server.get('*', (req, res) => {
13 const context = {};
14 const app = ReactDOMServer.renderToString(
15 React.createElement(
16 StaticRouter,
17 { location: req.url, context: context },
18 React.createElement(App)
19 )
20 );
21
22 if (context.url) {
23 res.redirect(context.url);
24 } else {
25 res.send(`
26 <!DOCTYPE html>
27 <html>
28 <head>
29 <title>Server Side Rendered App</title>
30 </head>
31 <body>
32 <div id='app'>${app}</div>
33 <script src='/bundle.js'></script>
34 </body>
35 </html>
36 `);
37 }
38});
39
40server.listen(3000, () => {
41 console.log('Server is running on port 3000');
42})
xxxxxxxxxx
})
const express = require('express');
const React = require('react');
const ReactDOMServer = require('react-dom/server');
const { StaticRouter } = require('react-router-dom');
const App = require('./App');
const server = express();
server.get('*', (req, res) => {
const context = {};
const app = ReactDOMServer.renderToString(
React.createElement(
StaticRouter,
{ location: req.url, context: context },
React.createElement(App)
)
);
if (context.url) {
res.redirect(context.url);
} else {
res.send(`
<!DOCTYPE html>
<html>
<head>
<title>Server Side Rendered App</title>
</head>
<body>
Are you sure you're getting this? Fill in the missing part by typing it in.
To implement ___ with React Router, we can use a server framework like Express and the ______________
from react-router-dom
.
Write the missing line below.
Conclusion
Congratulations on completing the React Router tutorial! You have learned how to implement client-side routing in a React application, allowing for smooth navigation and enhanced user experience.
React Router is a powerful library that provides a declarative syntax for defining routes and managing navigation in a single-page application. By using React Router, you can easily create complex routing structures, handle dynamic routes, and secure protected routes.
As you continue your journey in frontend development, React Router will be a valuable tool in your toolbox.
To further enhance your knowledge and skills, here are some additional resources:
- React Router Documentation
- React Router GitHub Repository
- Official React Documentation
- Codecademy - Learn React
- Frontend Masters - Complete Intro to React, v6
Keep practicing and building projects to showcase your skills as a frontend engineer. Good luck!
Let's test your knowledge. Fill in the missing part by typing it in.
React Router is a powerful library that provides a declarative syntax for defining routes and managing navigation in a single-page application. By using React Router, you can easily create complex routing structures, handle dynamic routes, and secure protected routes.
_ is a valuable tool in your frontend development toolbox.
Write the missing line below.
Generating complete for this lesson!