Answer the question
In order to leave comments, you need to log in
How to properly use useCallback and a function wrapped in memo?
It is clear that we must wrap the function in useCallback if we want to pass it to the inner component wrapped in memo. But what if I want to pass the "setIsOpen" function from useState to the inner component? Can it just be passed around or does it need to be wrapped as well?
const [isOpen, setIsOpen] = useState(false);
Answer the question
In order to leave comments, you need to log in
I wonder what the documentation has to say about the state update function? Yes, here's what :
React ensures that the function identity is setState
stable and doesn't change across re-renders.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question