Closed Brendonovich closed 5 months ago
Latest commit: 052d3856bad1484c24e23bdf5b74cf49aab870a6
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Thanks. Regardless of other repercussions and downstream considerations this probably makes a lot of sense.
It can be useful (and sometimes necessary) to access contexts declared above the
<Router>
inside loaders. In my case, we are preloading data using tRPC, which relies onuseQueryClient
to pull the tanstack query client out of context. This context provider is registered above the<Router>
, ie. available at the top-level where loaders execute, but is currently inaccessible as load functions are not run in the context of any owner. To allow this to work, I've simply grabbed the router's owner and wrapped the loader invocation withrunWithOwner
. While this does work, I wouldn't be surprised if also wrapping the loader invocation withcreateRoot
is necessary to account for some hooks that may read from context and create effects.