You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The select component is in uncontrolled mode. After selecting the value, modify the options, and the label of the value does not follow the modification #45734
Activity
ouzhou commentedon Nov 8, 2023
find a solution, just remove undefined determine below
to
https://github.com/react-component/select/blob/ec0c6c748a24aa500ede15f1d2aacd0dacf4f63b/src/Select.tsx#L275
https://github.com/react-component/select/blob/ec0c6c748a24aa500ede15f1d2aacd0dacf4f63b/src/Select.tsx#L277
ouzhou commentedon Nov 8, 2023
because when component re-render, rawLabel and rawKey not be re-assign value
chenmijiang commentedon Nov 9, 2023
for controlled components, your usage of the "onChange" method is wrong. It is not a native method. Just pass the value directly, like this:

ouzhou commentedon Nov 9, 2023
i fixed the demo
bbb169 commentedon Dec 22, 2023
https://github.com/react-component/select/blob/ec0c6c748a24aa500ede15f1d2aacd0dacf4f63b/src/Select.tsx#L289
本质还是internalValue这个值在select选择的时候会被triggerChange改变,当新的选项刷新试就会走到这个逻辑,要不要在这块增加一个逻辑,如果新旧label不匹配,就更新internalValue为新的值呢
afc163 commentedon Dec 22, 2023
@bbb169 思路是可以的,但是最好不要在 convert2LabelValues 里做。convert2LabelValues 最好是个纯函数,不应该加副作用。