|
3 | 3 | Welcome to your first exercise! In this exercise, |
4 | 4 | you will learn how to register routes in a React Router application. |
5 | 5 |
|
6 | | -## Exercise Overview |
| 6 | +## Understanding the `routes.ts` file |
| 7 | + |
| 8 | +The `app/routes.ts` file is where you define the routes for your application. Each route corresponds to a specific URL path |
| 9 | +and is associated with a React component that will be rendered when the user navigates to that path. |
| 10 | + |
| 11 | +This file is picked up by the React Router vite plugin and is used to generate the routing configuration for your app. |
| 12 | +What's important to keep in mind is that this in the end, is just a regular TypeScript file, so you can use all the features of TypeScript |
| 13 | +to help you define your routes. You can fetch them from third-parties, define helper functions, and so on. |
| 14 | + |
| 15 | +React router offers you a few utilities to help you define your routes more easily. |
| 16 | + |
| 17 | +## Exercise Goals |
7 | 18 |
|
8 | 19 | In this exercise, you will: |
9 | 20 |
|
10 | 21 | 1. Explore the `app/routes` directory. |
11 | | -2. Register those routes in the `app/routes.ts` file. |
12 | | -3. (Bonus) Create a utility to easily define landing page routes. |
13 | | - |
14 | | -## Getting Started |
| 22 | +2. Learn about the utilites offered by React Router to define routes. |
| 23 | +3. Register those routes in the `app/routes.ts` file. |
| 24 | +4. (Bonus) Create a utility to easily define landing page routes. |
15 | 25 |
|
16 | 26 | To get started, find our helpful assistants comments in the `app/routes.ts` file. (They include 🐨 emoji) |
17 | | -and implement the following routes: |
18 | | - |
19 | | -- `Landing page layout` that wraps all the other routes (`./routes/_landing.tsx`). |
20 | | -- `/` - The index route that renders the landing page (`./routes/_landing._index/route.tsx`). |
21 | | -- `/about` - The about route that renders the `About` page (`./routes/_landing.about.tsx`). |
22 | | -- `/products` - The products route that renders the `Products` page (`./routes/_landing.products._index.tsx`). |
23 | | -- `/products/:productId` - The product details route that renders the `ProductDetails` page (`./routes/_landing.products.$productId.tsx`). |
24 | | -- `/contact` - The contact route that renders the `Contact` page (`./routes/_landing.contact.tsx`). |
25 | | -- `/cart` - The cart route that renders the `Cart` page (`./routes/_landing.cart.tsx`). |
26 | | -- `/terms-of-use` - The terms of use route that renders the `TermsOfUse` page (`./routes/_landing.terms-of-use.tsx`). |
27 | | -- `/terms-of-service` - The terms of service route that renders the `TermsOfService` page (`./routes/_landing.terms-of-service.tsx`). |
28 | | - |
29 | | -> Bonus (only after completing the above): Create a utility function to easily define landing page routes. |
30 | | -> This utility should be used to define the routes above |
| 27 | +and implement the required routes for this project! |
0 commit comments