woocommerce-blocks icon indicating copy to clipboard operation
woocommerce-blocks copied to clipboard

Local Storage usage in Blocks doesn't react to changes in other windows.

Open senadir opened this issue 1 year ago • 0 comments

We use Local Storage somehow in Cart/Checkout/Mini Cart, mainly for mini cart totals, and nonces and other info, however, that local storage doesn't react to changes coming from other windows, meaning you can end up with a stale data in a window that wouldn't work and would cause your requests to fail or totals to not be updated.

Solution

  • First, unify usage of local storage to the useLocalStorageState hook instead of individual calls here and there. - Add event reaction for the storage event so that memory copies of storage data is updated if local storage is updated in another window.

senadir avatar Oct 18 '23 10:10 senadir