useLoaderData not returning data from closest route #8116
-
Hi everyone, this message is to understand what I'm doing wrong with nested routes. I understood that useLoaderData "Returns the serialized data from the closest route loader." as the docs say. So I setup a very simple example with these routes
I added a different text in each of them to make sure they were rendering correctly, and they were fine. Then I tried to add a loader My example.tsx looks like this:
example._index.tsx
but now there is an error when I visit TypeError: Cannot destructure property 'message' of 'useLoaderData3(...)' as it is null. So it seems I understood the whole thing wrong, I assumed by using useLoaderData I could access the data loaded in the route loader. What am I doing wrong? Many thanks - and thanks for remix |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It gives access to the data returned by the loader defined in the same route module. It won’t get data from a parent. |
Beta Was this translation helpful? Give feedback.
It gives access to the data returned by the loader defined in the same route module. It won’t get data from a parent.