akachicon / react-use-batched-state

Same as React.useState but batches updates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: `setState` function changes on every re-render

ChocolateLoverRaj opened this issue · comments

In the normal React.useState(), the setState function never changes. This is great when used in a React.useEffect() dependency array, because then it is not called every time the setState function changes.

However, useBatchedState behaves differently than expected. The setter function changes on every re-render, which can mess up calls to React.useEffect.

Link to reproduction

  • I can make a pull request fixing this issue.