question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Watch not re-rendering when input value property changes

See original GitHub issue

Describe the bug Assigning value directly to an input is not triggering watch re-render when value changes.

To Reproduce https://codesandbox.io/s/react-hook-form-watch-v6-forked-ydwdn?file=/src/index.js

Enter a value in the first field. The second field is correctly updated but in the console, the value returned by watch("name2") is outdated. (no re-render were triggered)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mrluboscommented, Nov 3, 2020

@cwagner22 Works now! May I ask what’s the use case for this? I’m not sure if it’s really a bug as you’d be getting double render on every key stroke

1reaction
mrluboscommented, Nov 3, 2020

Hi @cwagner22, your CodeSandbox link seems to be a broken build (referencing undefined value test)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem of re-rendering useEffect with watch all fields using ...
You are using react-hook-form watch method. this method will re-render at the root level of the app whenever a field value is changed....
Read more >
Changing @input value not rerendering the component. - Reddit
Hi, I am having this issue that changing the value of @input variable in the parent is no reinitializing the component again.
Read more >
How and when to force a React component to re-render
The component did not change, so there was no re-rendering trigger. Here's why. React evaluates state changes by checking its shallow equality ( ......
Read more >
Reactivity for Fields, Objects, and Arrays
If a field's value changes, and the field is used in a template or in a getter of a property that's used in...
Read more >
Lifting State Up - React
In React, this is usually solved by making a component “controlled”. Just like the DOM <input> accepts both a value and an onChange...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found