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: 4.0 table filters value may be previous #19873
Conversation
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.
Could you please add tests to make sure this change works as expected?
Deploy preview for ant-design ready! Built with commit 20a6540 |
@zombieJ added a test case |
Codecov Report
@@ Coverage Diff @@
## 4.0-prepare #19873 +/- ##
===============================================
+ Coverage 97.49% 97.49% +<.01%
===============================================
Files 291 292 +1
Lines 7231 7239 +8
Branches 1957 1996 +39
===============================================
+ Hits 7050 7058 +8
Misses 181 181
Continue to review full report at Codecov.
|
Create a hook name const [getFilteredKeys, setFilteredKeys] = React.useState(propFilteredKeys || []);
// ...
const onConfirm = () => {
internalTriggerFilter(getFilteredKeys());
}; |
getFilteredKeys(), It's not a function |
const [filteredKeys, setFilteredKeys] = React.useState(propFilteredKeys || []);
// ...
const onConfirm = () => {
internalTriggerFilter(filteredKeys);
}; |
Use this can't fix the bug |
I just correct this code errors. |
create a sync variable to resolve async 'setFilteredKeys'
|
I mean to create a hook your own to handle these code logic: // useSyncState.tsx
export default function useSyncState(...) {
const stateRef = React.useRef(...);
// ...
return [
() => stateRef.current;
(newValue) => ...
];
}
|
fix to this |
|
||
return [ | ||
() => filteredKeysRef.current, | ||
(newValue: T) => (filteredKeysRef.current = newValue), |
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.
Update filter should trigger re-render:
const [_, forceUpdate] = React.useState();
// ...
(newValue: T) => {
filteredKeysRef.current = newValue;
forceUpdate...
}
🤔 This is a ...
🔗 Related issue link
example:
https://codesandbox.io/s/elated-mendeleev-64277
💡 Background and solution
📝 Changelog
☑️ Self Check before Merge