Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useStateWithCallbackLazy - callback is not returned after state update complete #35

Open
jeevasusej opened this issue Nov 14, 2022 · 0 comments

Comments

@jeevasusej
Copy link

jeevasusej commented Nov 14, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant