usehooks icon indicating copy to clipboard operation
usehooks copied to clipboard

Fix useLocalStorage batch updates not working

Open Xedon opened this issue 8 months ago • 1 comments

useLocalStorage can not handle batch updates correctly, this PR will fix that.

It does not call the update function with the current state in the local storage. It uses the last "rendered" state which will not work if you call the callback multiple times without react rendering the component between calls.

Here is an example sandbox which shows our usecase.

In this Menu top left of the app. image

If you Click show all or hide all this will do batch updates on the useLocalStorage which will only toggle the last column and not all columns due to this bug. image

Xedon avatar Jun 10 '24 14:06 Xedon