Skip to content

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

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

msutkowski
Copy link
Member

I opted to show using useAppDispatch here, even though it would be fine to useDispatch. 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.

@github-actions
Copy link

github-actions bot commented Nov 9, 2021

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit (cjs.production.min.js) 12.23 KB (0%)
1. entry point: @reduxjs/toolkit (esm.js) 10.22 KB (0%)
1. entry point: @reduxjs/toolkit/query (cjs.production.min.js) 20.35 KB (0%)
1. entry point: @reduxjs/toolkit/query (esm.js) 17.37 KB (0%)
1. entry point: @reduxjs/toolkit/query/react (cjs.production.min.js) 22.22 KB (0%)
1. entry point: @reduxjs/toolkit/query/react (esm.js) 19.82 KB (0%)
2. entry point: @reduxjs/toolkit (without dependencies) (cjs.production.min.js) 5.56 KB (0%)
2. entry point: @reduxjs/toolkit (without dependencies) (esm.js) 5.53 KB (0%)
2. entry point: @reduxjs/toolkit/query (without dependencies) (cjs.production.min.js) 9.2 KB (0%)
2. entry point: @reduxjs/toolkit/query (without dependencies) (esm.js) 9.58 KB (0%)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (cjs.production.min.js) 2.37 KB (0%)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (esm.js) 2.21 KB (0%)
3. createSlice (esm.js) 5.16 KB (0%)
3. createEntityAdapter (esm.js) 5.83 KB (0%)
3. configureStore (esm.js) 5.83 KB (0%)
3. createApi (esm.js) 15.66 KB (0%)
3. createApi (react) (esm.js) 18.05 KB (0%)
3. fetchBaseQuery (esm.js) 10.93 KB (0%)
3. setupListeners (esm.js) 9.8 KB (0%)
3. ApiProvider (esm.js) 16.99 KB (0%)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 9, 2021

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:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
reduxjs/redux-toolkit Configuration

dispatch(api.util.prefetch(endpoint, arg, options))
}, [])
dispatch(api.util.prefetch(endpoint, arg as any, options))
}, [arg, dispatch, endpoint, options])
Copy link
Member

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)?

Copy link
Member Author

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 :)

Copy link
Member Author

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.

Copy link
Collaborator

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 :)

Copy link
Member

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?

@msutkowski msutkowski force-pushed the update-useprefetch-immediately-snippet branch from ec69726 to e788abc Compare November 16, 2021 02:03
@msutkowski msutkowski merged commit 2964b91 into master Nov 18, 2021
@msutkowski msutkowski deleted the update-useprefetch-immediately-snippet branch November 18, 2021 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants