Answer the question
In order to leave comments, you need to log in
In what cases will this useEffect work?
In the code below, useEffect in dependencies stores a reference to handler , as I understand it, it will be constant, due to the fact that the handler is wrapped in useCallback, i.e. the handler seems to never change, then what's the point of specifying it in the dependency array?
const handler = useCallback(() => {
// что-то сделать
}, [])
useEffect(() => {
handler(value)
// если не использовать useCallback, эффект будет срабатывать постоянно
},
[handler, value])
Answer the question
In order to leave comments, you need to log in
In what cases will this useEffect work?
What is the point of specifying it in the dependency array?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question