Update Router Context key/value
Hi all.
I was wondering if I'm missing the docs or if it's possible to reset one key/value pair in the router context when I do a mutation of data?
Basically I want to update the context from the component triggering the mutation.
I know about the router.invalidate(), but that resets the whole router context right?
Any tips would be much appreciated!
Cheers all.
2 Replies
continuing-cyan•5mo ago
I don’t think this is possible, as the result of beforeLoad and loaders can depend on the context value and modify it. There isn’t a dependency graph so everything need to be invalidated to be sure to have data in sync with context.
Depending on your usecase you might be able to get away with passing a filter function to invalidate specific routes but it seems very brittle to me
For this kind of granular updates, I would use react-query instead of router context
complex-tealOP•5mo ago
Hey Jaga. Thanks for your response. I'm guessing I've over complicated it all it seems. But I'll take the suggestion and try it out. Thinking about it it does make more sense to move it to query cache. Cheers!