-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update usePrefetchImmediately snippet #1710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
size-limit report 📦
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e788abc:
|
docs/rtk-query/usage/prefetching.mdx
Outdated
dispatch(api.util.prefetch(endpoint, arg, options)) | ||
}, []) | ||
dispatch(api.util.prefetch(endpoint, arg as any, options)) | ||
}, [arg, dispatch, endpoint, options]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add a dependency array here, we will need to keep arg
and options
stable.
Either we add a note to the docs or we export the tools we have in the query/react
package.
@markerikson what are your thoughts on exposing useShallowStableValue
and maybe even useStableQueryArgs
(the latter would need changes to be usable outside of the hooks internals)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I had that in the description, but wasn't sure if we need to talk about keeping those things stable as a part of this work or not. 100% agree with exposing useShallowStableValue
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markerikson Any thoughts here? I can always just revert this back to a dep array of []
just so we can get the arg as any
in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many other things going on, no thoughts here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep it with the []
for now and we'll think of the rest for the next release when we have resources?
ec69726
to
e788abc
Compare
I opted to show using
useAppDispatch
here, even though it would be fine touseDispatch
. I figured being that we're showing types, it's probably worthwhile to encourage it.I thought about including that if you were to provide
options
that you'd want to memo them, but also feel like that goes beyond this scope.