写这种效果的正确方法是什么
此代码仅适用于eslint警告,我认为可以忽略
const Select = ({ value }) => {
const [selectedOption, setSelectOption] = useState(() => value);
useEffect(
() => {
if (value !== selectedOption) {
setSelectOption(value);
}
},
// I need to ignore eslint rule here
// I need an effect that update my value when change from parent,
// but only when is different that the selected value to avoid
// rerenders and when is updated by the same component in onChange event
// that allow to use my component isoleted with any parent value
// eslint-disable-next-line
[value]
);
.
.
.
.