T
TanStack•13mo ago
metropolitan-bronze

HMR: Invariant failed: trying to access property 'id' on a route which is not initialized yet.

I'm experiencing this error when changing files. Refreshing the page makes the error disappear: Invariant failed: trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed. The stack trace points to a Route.useRouteContext call.
Uncaught Error: Invariant failed: trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.
invariant tiny-invariant.js:12
get id route.ts:898
useRouteContext route.ts:1174
AppLayout _app.tsx:109
React 14
performReactRefresh @react-refresh:267
performReactRefresh @react-refresh:256
setTimeout handler*debounce/< @react-refresh:666
validateRefreshBoundaryAndEnqueueUpdate @react-refresh:707
<anonymous> _app.tsx:1309
accept client:34
fetchUpdate client:218
queueUpdate client:193
queueUpdate client:193
handleMessage client:1325
handleMessage client:1323
setupWebSocket client:1233
setupWebSocket client:1232
<anonymous> client:1217
tiny-invariant.js:12:10
Uncaught Error: Invariant failed: trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.
invariant tiny-invariant.js:12
get id route.ts:898
useRouteContext route.ts:1174
AppLayout _app.tsx:109
React 14
performReactRefresh @react-refresh:267
performReactRefresh @react-refresh:256
setTimeout handler*debounce/< @react-refresh:666
validateRefreshBoundaryAndEnqueueUpdate @react-refresh:707
<anonymous> _app.tsx:1309
accept client:34
fetchUpdate client:218
queueUpdate client:193
queueUpdate client:193
handleMessage client:1325
handleMessage client:1323
setupWebSocket client:1233
setupWebSocket client:1232
<anonymous> client:1217
tiny-invariant.js:12:10
I cannot reproduce it with a simple context example. Does anyone have an idea what the reason could be?
3 Replies
metropolitan-bronze
metropolitan-bronzeOP•13mo ago
I get the same error when editing a Route without context when accessing loaderData:
Uncaught Error: Invariant failed: trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.
at invariant (chunk-TF5SSMVZ.js?v=e0f5f09d:294:9)
at get id (chunk-TF5SSMVZ.js?v=e0f5f09d:2949:5)
at Route.useLoaderData (chunk-TF5SSMVZ.js?v=e0f5f09d:2928:50)
at Hello (_app.hello.tsx:23:22)
at renderWithHooks (chunk-COU5HTJR.js?v=e0f5f09d:11548:26)
at updateFunctionComponent (chunk-COU5HTJR.js?v=e0f5f09d:14582:28)
at beginWork (chunk-COU5HTJR.js?v=e0f5f09d:15924:22)
at beginWork$1 (chunk-COU5HTJR.js?v=e0f5f09d:19753:22)
at performUnitOfWork (chunk-COU5HTJR.js?v=e0f5f09d:19198:20)
at workLoopSync (chunk-COU5HTJR.js?v=e0f5f09d:19137:13)
Uncaught Error: Invariant failed: trying to access property 'id' on a route which is not initialized yet. Route properties are only available after 'createRouter' completed.
at invariant (chunk-TF5SSMVZ.js?v=e0f5f09d:294:9)
at get id (chunk-TF5SSMVZ.js?v=e0f5f09d:2949:5)
at Route.useLoaderData (chunk-TF5SSMVZ.js?v=e0f5f09d:2928:50)
at Hello (_app.hello.tsx:23:22)
at renderWithHooks (chunk-COU5HTJR.js?v=e0f5f09d:11548:26)
at updateFunctionComponent (chunk-COU5HTJR.js?v=e0f5f09d:14582:28)
at beginWork (chunk-COU5HTJR.js?v=e0f5f09d:15924:22)
at beginWork$1 (chunk-COU5HTJR.js?v=e0f5f09d:19753:22)
at performUnitOfWork (chunk-COU5HTJR.js?v=e0f5f09d:19198:20)
at workLoopSync (chunk-COU5HTJR.js?v=e0f5f09d:19137:13)
I updated the dependencies and now the issue is gone. I tried way to long to reproduce this.. 😅
sunny-green
sunny-green•13mo ago
always try updating to the latest version, we fix the issues fast and release often ...
metropolitan-bronze
metropolitan-bronzeOP•13mo ago
Yeah. I always try to reproduce but I should update dependencies first

Did you find this page helpful?