Replies: 2 comments 11 replies
-
So what you are suggesting is: instead of passing a context to
and the created hooks could be:
Let me also tag @blackarctic as he implemented passing in the custom context. If it worked that way, would the custom context be unnecessary? I wouldn't really want to have both apis sticking around ... |
Beta Was this translation helpful? Give feedback.
-
It would be unecessary for isolation. But not relying on an instance to use the hooks will still easier for a majority of use cases. |
Beta Was this translation helpful? Give feedback.
-
Hello @TkDodo @tannerlinsley ,
Here is an idea to get rid of react context issues that come mainly from micro-frontend setups, users wanting to isolate context or bundler issues like #4346
The idea is to have something like tRPC client proxy or Zodios hooks instance that could allow to bind react-query
QueryClient
instance to your hooks without any react context involved.Indeed, context allows have separation of queryClient from hooks. Meaning you can have the same code used in different context and don't care which one is used.
But this use case is really rare. Usually when using multiple contexts it's to have isolation, meaning that for these use cases, the code is most likely not shared. Else why would you need isolation ?
So the idea is to remove context completely from the equation. Here an example :
Then in your isolated components
Obiously this design has some impact. For example to evoid duplicated implementation, you will want to implement this
@tanstack/react-query-hooks
above current@tanstack/react-query
.This means allow current hooks to not use context optionnally like this :
Let me know what you think about this.
Beta Was this translation helpful? Give feedback.
All reactions