#Cannot get context value on child route

10 messages · Page 1 of 1 (latest)

spring meadow
chrome stratus
#

Although you are fetching the user in the __root route, you aren't the result of the profile fetch into your auth-context.

#

and this isn't reflected on the index page, since you are consuming useAuth whilst it hasn't had the user added into it.

spring meadow
chrome stratus
spring meadow
chrome stratus
#

You can still access it in the beforeLoad callback.

#

There is a difference between the Router context and React context.
Its just that you happen to be injecting the React context into the Router's context, which is totally fine. Then its just a matter is choosing what is your source-of-truth.
Since you don't want to be storing the user data in both the Router's context as well as React's, because you then open yourself up to potential drift.

spring meadow
#

OK, I understand about Router context and React context. I can access Router context via Route.useRouteContext().