use-state-with-callback icon indicating copy to clipboard operation
use-state-with-callback copied to clipboard

useStateWithCallbackLazy - callback is not returned after state update complete

Open jeevasusej opened this issue 1 year ago • 0 comments

State has been updated but inside the callback I am getting the old value of component.

const [count, setCount] = useStateWithCallbackLazy(0);

  const handleClick = () => {
    setCount(count + 1, (currentCount) => {
      console.log('current count value - ' + count);
    });
  };

The same question has been updated in stackoverflow: https://stackoverflow.com/questions/74442587/getting-state-old-value-on-react-custom-hook-callback#74442942

jeevasusej avatar Nov 14 '22 08:11 jeevasusej