Skip to content
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

feature: allow using skipSymbol as arg in hooks #1056

Merged
merged 3 commits into from
May 16, 2021

Conversation

phryneas
Copy link
Member

This still needs tests.

This will resolve

Thanks @omerman for the suggestion.

Naming is as always up for debate. @omerman suggested skipToken which should also fit the bill fine.

@markerikson opinions?

Comment on lines +21 to +43
/**
* Can be passed into `useQuery`, `useQueryState` or `useQuerySubscription`
* instead of the query argument to get the same effect as if setting
* `skip: true` in the query options.
*
* Useful for scenarios where a query should be skipped when `arg` is `undefined`
* and TypeScript complains about it because `arg` is not allowed to be passed
* in as `undefined`, such as
*
* ```ts
* // codeblock-meta title="will error if the query argument is not allowed to be undefined" no-transpile
* useSomeQuery(arg, { skip: !!arg })
* ```
*
* ```ts
* // codeblock-meta title="using skipSymbol instead" no-transpile
* useSomeQuery(arg ?? skipSymbol)
* ```
*
* If passed directly into a query or mutation selector, that selector will always
* return an uninitialized state.
*/
export const skipSymbol = Symbol('skip selector')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should describe what it does ;)

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 15, 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 ecaf556:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration

@github-actions
Copy link

Size Change: +220 B (0%)

Total Size: 535 kB

Filename Size Change
dist/query/react/rtk-query-react.cjs.development.js 17.7 kB +6 B (0%)
dist/query/react/rtk-query-react.cjs.production.min.js 11.2 kB +24 B (0%)
dist/query/react/rtk-query-react.esm.js 17.3 kB +6 B (0%)
dist/query/react/rtk-query-react.modern.development.js 14.3 kB +9 B (0%)
dist/query/react/rtk-query-react.modern.js 14.3 kB +12 B (0%)
dist/query/react/rtk-query-react.modern.production.min.js 9.39 kB +21 B (0%)
dist/query/react/rtk-query-react.umd.js 187 kB +15 B (0%)
dist/query/react/rtk-query-react.umd.min.js 62.9 kB +13 B (0%)
dist/query/rtk-query.cjs.development.js 15 kB +16 B (0%)
dist/query/rtk-query.cjs.production.min.js 9.52 kB +18 B (0%)
dist/query/rtk-query.esm.js 14.7 kB +13 B (0%)
dist/query/rtk-query.modern.development.js 11.9 kB +14 B (0%)
dist/query/rtk-query.modern.js 12 kB +14 B (0%)
dist/query/rtk-query.modern.production.min.js 7.83 kB +9 B (0%)
dist/query/rtk-query.umd.js 27.5 kB +16 B (0%)
dist/query/rtk-query.umd.min.js 16.2 kB +14 B (0%)
ℹ️ View Unchanged
Filename Size Change
dist/index.js 146 B 0 B
dist/query/index.js 144 B 0 B
dist/query/react/index.js 149 B 0 B
dist/redux-toolkit.cjs.development.js 11.9 kB 0 B
dist/redux-toolkit.cjs.production.min.js 5.8 kB 0 B
dist/redux-toolkit.esm.js 11.6 kB 0 B
dist/redux-toolkit.modern.development.js 9.5 kB 0 B
dist/redux-toolkit.modern.js 9.54 kB 0 B
dist/redux-toolkit.modern.production.min.js 4.51 kB 0 B
dist/redux-toolkit.umd.js 21.9 kB 0 B
dist/redux-toolkit.umd.min.js 10.7 kB 0 B

compressed-size-action

@netlify
Copy link

netlify bot commented May 15, 2021

Deploy preview for redux-starter-kit-docs ready!

Built with commit ecaf556

https://deploy-preview-1056--redux-starter-kit-docs.netlify.app

@phryneas phryneas marked this pull request as ready for review May 16, 2021 15:08
@phryneas phryneas merged commit 9dc67fd into feature/v1.6-integration May 16, 2021
@phryneas phryneas deleted the feature/skipSymbol branch May 16, 2021 19:10
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.

1 participant