Skip to content

Conversation

filiperni
Copy link

@filiperni filiperni commented Oct 2, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

  • Select function passed to useQuery is recreated on each render
  • This causes unnecessary re-execution of the select function every time the useList hook runs.
  • When the select function passed to useList (through queryProps) triggers a re-render, for example by updating some state, it causes a inifite loop. Like described in issue [BUG] setState in useList queryOptions select causes infinite loop #7022.

What is the new behavior?

fixes #7022
fixes #6713

  • Memoizes the select function passed to useQuery in useList hook
  • Now select function is called only when:
    1. useQuery data changes
    2. pagination properties change in use useList

Notes for reviewers

Added an example project to test out the behaviour of useList when passing query params with memoized select function.
I'm not sure if I should leave this project in repo or should I delete it.

pnpm-lock file was automatically updated after running pnpm install

@filiperni filiperni requested a review from a team as a code owner October 2, 2025 13:58
Copy link

changeset-bot bot commented Oct 2, 2025

🦋 Changeset detected

Latest commit: 7506fbc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for refine-doc-live-previews ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7506fbc
🔍 Latest deploy log https://app.netlify.com/projects/refine-doc-live-previews/deploys/68ed013f773b8100088b3c0b
😎 Deploy Preview https://deploy-preview-7039--refine-doc-live-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.


.menu {
flex-shrink: 0;
padding: 8px 16px;

Choose a reason for hiding this comment

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

I think relative sizing would be better.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your comment. I would leave it as is because the UI in this example project is not important.
I created this example project using the refine CLI command to test out if the useList hook works properly.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, I don't even use these stylings. So I removed them.

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.

[BUG] setState in useList queryOptions select causes infinite loop [BUG] queryOptions.select runs multiple times

2 participants