Skip to content

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

@jeevasusej

Description

@jeevasusej

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions