field-form
field-form copied to clipboard
useWatch doesn't call setState when it is object that same but not equal
reproduce
https://codesandbox.io/s/sweet-banach-t7cpoq
case 1
- If you click
pushbutton,foois displayed in two input boxes
case 2
- First, click
setFieldValuebutton - Next, click
pushbutton,foois displayed in the input box below, but not in above box.
cause
https://github.com/react-component/field-form/blob/master/src/useWatch.ts#L99
if (valueStrRef.current !== nextValueStr) {
valueStrRef.current = nextValueStr;
setValue(newValue);
}
it compares stringified objects. Strings are same but objects are not
I think this problem is conflicts with this issue(https://github.com/react-component/field-form/issues/431)