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

fix(query-core): allow function value of notifyOnChangeProps query option to return undefined #7441

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

winghouchan
Copy link
Contributor

undefined is a valid return value for the function value of notifyOnChangeProps. See linked issue for more details.

Fixes #7426.

Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview Jun 8, 2024 5:42pm

Copy link

codesandbox-ci bot commented May 16, 2024

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

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

@TkDodo
Copy link
Collaborator

TkDodo commented May 16, 2024

can you amend the signature in the docs as well please?

Copy link

nx-cloud bot commented May 16, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 76abb16. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@TkDodo
Copy link
Collaborator

TkDodo commented May 16, 2024

also the jsdoc please:

/**
* If set, the component will only re-render if any of the listed properties change.
* When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.
* When set to `'all'`, the component will re-render whenever a query is updated.
* When set to a function, the function will be executed to compute the list of properties.
* By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
*/
notifyOnChangeProps?: NotifyOnChangeProps

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 17, 2024

@winghouchan will you get this PR over the finish line or should I do it?

Copy link

pkg-pr-new bot commented Jul 17, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

commit: 76abb16

@tanstack/angular-query-devtools-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@7441

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@7441

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@7441

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@7441

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@7441

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@7441

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@7441

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@7441

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@7441

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@7441

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@7441

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@7441

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@7441

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@7441

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@7441

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@7441

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@7441

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@7441

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@7441

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@7441

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@7441


templates

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.33%. Comparing base (a87c2fe) to head (22c3569).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           main    #7441       +/-   ##
=========================================
+ Coverage      0   63.33%   +63.33%     
=========================================
  Files         0      125      +125     
  Lines         0     4522     +4522     
  Branches      0     1259     +1259     
=========================================
+ Hits          0     2864     +2864     
- Misses        0     1430     +1430     
- Partials      0      228      +228     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental 86.58% <ø> (∅)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister 43.85% <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core 92.87% <ø> (∅)
@tanstack/query-devtools 5.24% <ø> (∅)
@tanstack/query-persist-client-core 57.73% <ø> (∅)
@tanstack/query-sync-storage-persister 82.50% <ø> (∅)
@tanstack/react-query 92.98% <ø> (∅)
@tanstack/react-query-devtools 10.71% <ø> (∅)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (∅)
@tanstack/solid-query 78.06% <ø> (∅)
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client 100.00% <ø> (∅)
@tanstack/svelte-query 90.00% <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client 100.00% <ø> (∅)
@tanstack/vue-query 71.42% <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)

…option to return `undefined`

`undefined` is a valid return value for the function value of `notifyOnChangeProps`. See linked issue for more details.

Fixes TanStack#7426.
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 17, 2024
@winghouchan
Copy link
Contributor Author

@TkDodo: sorry, missed your messages.

I've updated the signature in documentation in 43f0722. As far as I can tell it only affects React (and Vue, although they share the same docs). Please let me know if this is incorrect.

How would you like the JSDoc updated? The current description isn't wrong, although I suppose it could be improved. Maybe something like below:

  • If set to a function, the function will be executed to compute the list of properties.
  • If the value is set or computed to undefined, access to properties will be tracked, and the component will only re-render when one of the tracked properties change. This is the default behaviour.
  • If the value is set or computed to an array, the component will only re-render if any of the listed properties change. For example, if the value is set to or computed to ['data', 'error'], the component will only re-render when the data or error properties change.
  • If the value is set or computed to "all", the component will opt-out of smart tracking and re-render whenever a query is updated.

@TkDodo TkDodo merged commit 0c671ee into TanStack:main Jul 18, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation package: query-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function passed to notifyOnChangeProps cannot return undefined
2 participants