T
TanStack4mo ago
graceful-blue

`loaderData` always possibly undefined in the `head` ?

Hello, I see that from the types, the loaderData in the head of a route can always be undefined, but in my test it always returns the value of the loader ? Can we use the data or it can be possibly underfined thus useless ?
No description
4 Replies
robust-apricot
robust-apricot4mo ago
head is invoked also when a loader fails
graceful-blue
graceful-blueOP4mo ago
Oh okay I see make sens, so we can take for granted that if there is no failure, the data will be defined ?
robust-apricot
robust-apricot4mo ago
yes but you need to check in head if loader data is defined
graceful-blue
graceful-blueOP4mo ago
yes ofc, thank you !

Did you find this page helpful?