Both watch and watchEffect are used for running side effects when there is a change to a dependency, and it is my understanding that useEffect is also used for that purpose.
One difference is that React requires explicit tracking of dependencies, unlike Vue watchEffect, which does that for you under-the-hood.
So react useEffect is written like this:
useEffect(callback,[dependencies]);
But Vue watchEffect is just:
watchEffect(callback)
I guess Vue watch is more like React useEffect since it requires you to write the dependencies first, then add a callback to run the side effect:
watch([dependencies],(callback)})
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is watchEffect the same as useEffect() in React ??
Both
watchandwatchEffectare used for running side effects when there is a change to a dependency, and it is my understanding thatuseEffectis also used for that purpose.One difference is that React requires explicit tracking of dependencies, unlike Vue
watchEffect, which does that for you under-the-hood.So react
useEffectis written like this:But Vue
watchEffectis just:I guess Vue
watchis more like ReactuseEffectsince it requires you to write the dependencies first, then add a callback to run the side effect: