React·100 questions

How to correctly specify dependencies for useEffect?

Answer
List all values used inside the effect.
Do not disable eslint rules without reason.
Use useCallback for functions.
Use useMemo for objects.
If the effect is too 'noisy' — reconsider the architecture.
Was this answer helpful?

More questions in this topic

Related questions from other topics