更新时间:2022-12-30 21:12:30
我自己遇到了这个问题,并通过将key
传递给React-Select组件并附加了选定的值来设法解决了这个问题.然后这将强制
I came across this problem myself and managed to fix it by passing a key
to the React-Select component, with the selected value appended to it. This will then force the ReactSelect
to re-render itself when the selection is updated.
我希望这对某人有帮助.
I hope this helps someone.
import ReactSelect from 'react-select';
...
<ReactSelect
key={`my_unique_select_key__${selected}`}
value={selected || ''}
...
/>