@@ -4,6 +4,17 @@ summary: "The Devtools context provides tracing utilities for loaders and action
44description : " Using the devtools context to trace events and send them to the network tab"
55---
66
7+ ## TanStack DevTools Integration
8+
9+ React Router Devtools v6+ integrates with [ TanStack DevTools] ( https://tanstack.com/devtools ) , providing enhanced debugging capabilities alongside React Router specific features. The devtools now include:
10+
11+ - React Router specific tabs (Active Page, Routes, Network, Timeline, Settings)
12+ - TanStack DevTools panels for advanced state inspection
13+ - Unified debugging experience with seamless integration
14+
15+ You can configure TanStack-specific behavior through the [ general configuration] ( /configuration/general#tanstack-devtools-integration ) .
16+
17+ ---
718
819## Devtools extended context
920
@@ -19,9 +30,9 @@ export const loader = async ({ request, devTools }: LoaderFunctionArgs) => {
1930 const tracing = devTools ?.tracing ;
2031 // tracing is a set of utilities to be used in your data fetching functions to trace events
2132 // in network tab of react-router-devtools
22- const startTime = tracing .start (" my-event" )
33+ const end = tracing .start (" my-event" )
2334 // do something here, eg DB call
24- tracing . end (" my-event " , startTime ! )
35+ end ()
2536 return " data"
2637}
2738```
@@ -33,9 +44,9 @@ export const action = async ({ request, devTools }: ActionFunctionArgs) => {
3344 const tracing = devTools ?.tracing ;
3445 // tracing is a set of utilities to be used in your data fetching functions to trace events
3546 // in network tab of react-router-devtools
36- const startTime = tracing ?.start (" my-event" )
47+ const end = tracing ?.start (" my-event" )
3748 // do something
38- tracing ?. end (" my-event " , startTime ! )
49+ end ()
3950 return " data"
4051}
4152```
@@ -47,9 +58,9 @@ export const clientLoader = async ({ request, devTools }: ClientLoaderFunctionAr
4758 const tracing = devTools ?.tracing ;
4859 // tracing is a set of utilities to be used in your data fetching functions to trace events
4960 // in network tab of react-router-devtools
50- const startTime = tracing ?.start (" my-event" )
61+ const end = tracing ?.start (" my-event" )
5162 // do something
52- tracing ?. end (" my-event " , startTime ! )
63+ end ()
5364 return " data"
5465}
5566```
@@ -59,9 +70,9 @@ export const clientAction = async ({ request, devTools }: ClientActionFunctionAr
5970 const tracing = devTools ?.tracing ;
6071 // tracing is a set of utilities to be used in your data fetching functions to trace events
6172 // in network tab of react-router-devtools
62- const startTime = tracing ?.start (" my-event" )
73+ const end = tracing ?.start (" my-event" )
6374 // do something
64- tracing ?. end (" my-event " , startTime ! )
75+ end ()
6576 return " data"
6677}
6778```
@@ -103,10 +114,9 @@ const loader = async ({ request, devTools }: LoaderFunctionArgs) => {
103114The tracing object contains all the utilities related to network tab tracing feature of react-router-devtools.
104115
105116
106- There are three functions you can use:
117+ There are two functions you can use:
107118- trace
108119- start
109- - end
110120
111121
112122
@@ -143,18 +153,18 @@ This is used together with `end` to trace the time of the event.
143153export const loader = async ({ request , devTools }: LoaderFunctionArgs ) => {
144154 const tracing = devTools ?.tracing ;
145155 // this will be traced in the network tab of react-router-devtools
146- const startTime = tracing ?.start (" my-event" )
156+ const end = tracing ?.start (" my-event" )
147157 // do something here, eg DB call
148158
149159 // End the trace
150- tracing ?. end (" my-event " , startTime ! )
160+ end ()
151161 return " data"
152162}
153163```
154164
155165<WarningAlert title = " Warning" >
156- This function relies on you using the ` end ` with the same name as the start event, otherwise
157- you will end up having a never ending loading bar in the network tab!
166+ This function relies on you using the ` end ` returned from it, otherwise the event
167+ will never end in your devtools
158168</WarningAlert >
159169
160170
@@ -164,32 +174,4 @@ you will end up having a never ending loading bar in the network tab!
164174
165175#### Returns
166176
167- The start time of the event
168-
169- ### end
170-
171- The ` end ` function is a function that will end a trace for the name provided to it and return the end time.
172-
173- ``` ts
174- export const loader = async ({ request , devTools }: LoaderFunctionArgs ) => {
175- const tracing = devTools ?.tracing ;
176- // this will be traced in the network tab of react-router-devtools
177- const startTime = tracing ?.start (" get user" )
178- // do something here, eg DB call
179- const user = await getUser ();
180- // End the trace
181- tracing ?.end (" get user" , startTime ! , { user })
182- return " data"
183-
184- }
185- ```
186-
187- #### Parameters
188-
189- - ` name ` - The name of the event
190- - ` startTime ` - The start time of the sendEvent
191- - ` data ` - The data to be sent with the event
192-
193- #### Returns
194-
195- The data provided in the last parameter
177+ The end trace function
0 commit comments