load store immediately
friksa opened this issue · comments
Currently, the store presents the default value first before loading the data from localstore. The effect is that it flashes the default value before presenting the stored values.
It would be better if the default values are only used if no data present in localstorage.... otherwise, it should always start with data from localstorage.
Thanks for a great project!
After further investigation, it's clear that the issue is related to SSR (Server Side Rendering).
For anyone that runs across this in the future you can prevent the displaying of the wrong state by using browser.
<script>
import { browser } from '$app/environment'
import { layout } from "./stores"
</script>
{#if browser}
<$layout stuff to be rendered from client>
{:else}
<placeholder material>
{/if}
You can minimize the pop in effect this way.