|
| 1 | +# React Router DevTools |
| 2 | + |
| 3 | +Date: 2025-05-05 |
| 4 | + |
| 5 | +Status: accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +Epic Stack uses React Router for routing. React Router is a powerful |
| 10 | +library, but it can be difficult to debug and visualize the routing |
| 11 | +in your application. This is especially true when you have a complex |
| 12 | +routing structure with nested routes, dynamic routes, and you rely |
| 13 | +on data functions like loaders and actions, which the Epic Stack does. |
| 14 | + |
| 15 | +It is also hard to know which routes are currently active |
| 16 | +(which ones are rendered) and if any if the loaders are triggered |
| 17 | +when you expect them to be. This can lead to confusion and frustration |
| 18 | +and the use of console.log statements to debug the routing in your |
| 19 | +application. |
| 20 | + |
| 21 | +This is where the React Router DevTools come in. The React |
| 22 | +Router DevTools are a set of tools that do all of these things for you. |
| 23 | + |
| 24 | +React Router has a set of DevTools that help debug and visualize the |
| 25 | +routing in your application. The DevTools allow you to see the |
| 26 | +current route information, including the current location, the matched |
| 27 | +routes, and the route hierarchy. This can be very helpful when debugging |
| 28 | +your applications. The DevTools also hook into your server-side by |
| 29 | +wrapping loaders and actions, allowing you to get extensive |
| 30 | +information about the data being loaded and the actions being dispatched. |
| 31 | + |
| 32 | +## Decision |
| 33 | + |
| 34 | +We will add the React Router DevTools to the Epic Stack. The DevTools |
| 35 | +will be added to the project as a development dependency. The DevTools |
| 36 | +will be used in development mode only. |
| 37 | + |
| 38 | +The DevTools will be used to enhance the following: |
| 39 | + |
| 40 | +1. Visualize the routing in your application |
| 41 | +2. Debug the routing in your application |
| 42 | +3. See the returned loader data and action data in the DevTools |
| 43 | +4. Open routes in your editor directly from the browser |
| 44 | +5. See the route boundaries in your application |
| 45 | +6. See cache information returned via headers from your loaders |
| 46 | +7. See which loaders/actions are triggered when you navigate to a route |
| 47 | +8. and a lot more! |
| 48 | + |
| 49 | + |
| 50 | +## Consequences |
| 51 | + |
| 52 | +With the addition of the React Router DevTools, you will not have to rely on |
| 53 | +console.log statements to debug your routing. The DevTools will provide you |
| 54 | +with the tools to ship your applications faster and with more confidence. |
| 55 | + |
| 56 | +The DevTools will also help you visualize the routing in your application, |
| 57 | +which can be very helpful in understanding routing in general, and figuring |
| 58 | +out if your routes are set up correctly. |
| 59 | + |
| 60 | +They are not included in the production build by default, so you will not |
| 61 | +have to worry about them being included in your production bundle. |
| 62 | +They are only included in development mode, so you can use them without |
| 63 | +any negative performance impact in production. |
0 commit comments