react-component / react-component/field-form
useWatch doesn't call setState when it is object that same but not equal
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 286
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 1
Description
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce both cases in the linked CodeSandbox, then inspect src/useWatch.ts around line 99 where the stringified objects are compared. Check the relationship with issue #431; done means the two input boxes stay consistent after setFieldValue followed by push.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100