Skip to content

Outlet works only with one level of nesting #1172

Closed Answered by sergiodxa
ronyv89 asked this question in Q&A
Discussion options

You must be logged in to vote

First, why this happens, each Outlet renders a new Provider for the context it uses internally, and because there's no way to automatically know how to merge your Outlet data React Router (because this comes from RR not from Remix) can't automatically extend the data.

Now, a few ideas:

  1. Whenever you render an Outlet call useOutletContext, get the parent route data and pass it to the new Outlet.
  2. Create a specific context for your nabber, this is probably the safest thing to do.
  3. If your data from the navbar comes from the loader result you can use the useMatches hook to access it from any other route (child or parent, doesn't matter).
  4. If your data is static, add it to the handle export and …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by machour
Comment options

You must be logged in to vote
0 replies
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