-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(core): wrap setFiltersFn
with useCallback
#6386
Conversation
🦋 Changeset detectedLatest commit: 990f8e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @hugorezende thank you for the PR! I've made a small change request in the changeset and left two comments for the dependency arrays, can you check them and apply the necessary changes? 🙏
Then, we can include this in our next release 🚀 🚀
unionFilters(preferredPermanentFilters, newFilters, prevFilters), | ||
); | ||
}, | ||
[setFilters, unionFilters, preferredPermanentFilters], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setFilters
is a SetStateAction and unionFilters
is an imported util, they don't need to be included in the dependency arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can you make a similar update in the setSortWithUnion
function as well? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.changeset/spotty-jokes-swim.md
Outdated
"@refinedev/core": patch | ||
--- | ||
|
||
fix: fix setFiltersFn #6385 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: fix setFiltersFn #6385 | |
fix(core): wrap `setFilters` and `setSorters` methods with `useCallback` to prevent looping re-renders |
Having a bit more info in the first line will be great for the changelogs 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
Adding the
setFilters
as a dependency in the useEffect hook causes infinite loop since setFiltersFn are not wrapped inuseCallbacks
What is the new behavior?
No infinite loop
fixes #6385