However setSelectedKeys uses setState and confirm reads the same value from state, so when setState is asynchronous, the confirm will use the previous value of selected keys, not the new value.
The solution for now is to use a setTimeout but that's not very nice, maybe a better way would be to change setSelectedKeys to accept an optional callback that can be passed to setState
Version
3.9.2
Environment
react 16
Reproduction link
Steps to reproduce
I'm trying to use a DatePicker.RangePicker as a custom filter inside a Table and I've implemented the custom filter function as
However setSelectedKeys uses
setState
and confirm reads the same value from state, so whensetState
is asynchronous, theconfirm
will use the previous value of selected keys, not the new value.The solution for now is to use a
setTimeout
but that's not very nice, maybe a better way would be to changesetSelectedKeys
to accept an optional callback that can be passed tosetState
What is expected?
I expect the dropdown filter to work all the times
What is actually happening?
Often the table doesn't filter correctly because it uses stale data
The text was updated successfully, but these errors were encountered: