Closed surahe closed 4 years ago
Generally with autorun
you don't need to worry about deps argument to useEffect
. Any observables will be identified automatically. Your example is too contrived as it doesn't use any observables in the autorun, so you cannot really see the difference.
See more here: https://mobx-react.js.org/recipes-effects
@FredyC, this seems like a question and not so much an issue. Maybe it should be closed? @surahe, probably better to use the gitter or stack overflow for any future questions.
We don't mind open questions as an issue here, gitter is bad for tracking it later anyway. There is auto close configured and by commenting, you have reset it ;)
I use mobx-react-lite with hooks, while I use
setNumber
to change local state, or useaddNewTodo
to change global state, both autorun and useEffect can run.what's the difference between useEffect and autorun? On what condition will I use useEffect or autorun?
local state
global state
I read the issue 197,but I still don't know when should I use: