Update React Hook data and options from requests that have been initiated on middleware. #4629
georgeiliadis91
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Can you give some examples of what your app is actually doing, code-wise? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For complex applications middleware is the way to go.
Many times you might have queries that depend to a bunch of filter params.
Adding values those on useEffects can easily lead tp spaghetti code. Not to mention all the not needed rerendering that is gonna occur.
To avoid that middleware is the go to solution we can batch all the store updates/side effects in there when the global state changes.
Currently if I call an query via .initatie() inside my middleware when this resolves. If I have a useLazyMyQuery inside a component, the data, isLoading. isFetching etc do not see, to update ever.
Current solutions include creating selectors on the api.slices (which can become tedious especially on request with a lot of args), creating dedicated slices for data.
Ideally it would be nice to have the hooks update when the query resolves. Or even have a dedicated one.
Beta Was this translation helpful? Give feedback.
All reactions