-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Describe the bug
When using the select
function in queryOptions
of the useList
hook, it causes an infinite re-rendering loop. The component continuously re-fetches data and never stabilizes, making the application unusable.
The issue occurs specifically when the select
function is used to transform or filter the data returned from the API call within the useList
hook's query options.
Steps To Reproduce
- Create a component that uses useList hook
- Add queryOptions with a select function
- Call setState or any state setter inside the select function
- Observe infinite re-rendering in browser dev tools
const { data } = useList({
resource: "users",
queryOptions: {
select: (data) => {
// This causes infinite loop
setSomeState(data.items);
return data;
}
}
});

Expected behavior
The select function should be able to handle side effects like setState calls without causing infinite re-renders. The query should execute once and allow state updates based on the transformed data without triggering additional query executions.
Packages
"@ant-design/icons": "^5.5.1",
"@refinedev/antd": "^6.0.1",
"@refinedev/cli": "^2.16.48",
"@refinedev/core": "^5.0.1",
"@refinedev/devtools": "^2.0.1",
"@refinedev/react-router": "^2.0.0",
Additional Context
This issue commonly occurs when developers need to update component state based on the transformed query data. The current behavior makes it impossible to perform side effects within the select function, limiting its usefulness for data transformation scenarios that require state updates.