Skip to content

How can i split my routes from my CustomRouteProvider #10403

Closed Answered by brophdawg11
rory-ferguson asked this question in Q&A
Discussion options

You must be logged in to vote

You can't use data APIs within descendant <Routes> (docs), so this won't work:

<Route path="/*">
  <Route id="actionLogs" loader={async () => fetchActionLogs(profile)}>
    // rest of routes
    </Route>
</Route>

You can't access React hook values in loaders because the navigation data loading is entirely decoupled from the react render lifecycle and happens before any rendering. So at the time the hooks run there has been no react render to provide a hook-driven value.

Usually the answer here is to find the route source of truth for useAuth(). Does it read from some other global state? A cookie? That data is available somewhere client side so it can be put into a provider that the hook r…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MichaelDeBoey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants