Answer the question
In order to leave comments, you need to log in
Why doesn't data change in useCallback hook?
Data came from the back, and after that, when handleGraphSelectionChange is called, the data always remains the same and why?
const [data, setData] = useState({
nodes: [],
links: [],
updatedAt: {}
});
const handleGraphSelectionChange = useCallback(selectedNode => {
console.log(data);
setData({
nodes: data.nodes.slice(1,10),
links: [],
updatedAt: {}
});
}, [data]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question