usehooks
usehooks copied to clipboard
Fix useLocalStorage batch updates not working
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.
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.