3 ms·
> I like to use "location state" which is our API into the browser's built in `history.state` ... Location state, unlike typical "global state", automatically p
by baobabKoodaa 5y ago
> I like to use "location state" which is our API into the browser's built in `history.state` ... Location state, unlike typical "global state", automatically persists across both refreshes and back/forward button clicks, but dies with the session, so scroll restoration will work as expected even for a refresh! Built in browser APIs tend to be a bit more resilient than storing stuff in application memory, they also keep your bundle smaller.
This sounds great! I never thought of using history state to store arbitrary data. Thanks for the explanation!