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
useWatch's result is optimised for render phase instead of useEffect's deps, to detect value updates you may want to use an external custom hook for value comparison.
#12854
I have tested this and this works fine almost everytime, even when the watchedValue is an object ;like {id: 1, name: ''} =>{id:2}
but will it work everytime or there will be issues?
If this won't work can someone share a custom hook for this as written in the documentation for value comparison / detect updates and do something when a value changes..
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
What does the first line mean? render phase?
it isn't optimized but can we not use it like this at all:
const watchedVal = useWatch({name: 'someName'})
useEffect(()=> {
console.log(watchedVal)
},[watchedVal])
I have tested this and this works fine almost everytime, even when the watchedValue is an object ;like {id: 1, name: ''} =>{id:2}
but will it work everytime or there will be issues?
If this won't work can someone share a custom hook for this as written in the documentation for value comparison / detect updates and do something when a value changes..
Beta Was this translation helpful? Give feedback.
All reactions