nanostores / solid

Global state management in Solid using nanostores.
MIT License
73 stars 9 forks source link

`useStore()` shows incorrect initial value with '@nanostores/persistent' #18

Open qdwang opened 5 months ago

qdwang commented 5 months ago

Link: https://github.com/nanostores/persistent/issues/49

export default function () {
    const foo = useStore($foo); 

    console.log(foo())  // correct
    console.log($foo.get()) // correct
    createEffect(() => {
        console.log(foo()) // correct on every increment
    })

    return (
        <>
            <div>Foo: {foo()}</div>       // incorrect on page loaded
            <button class="button is-small" onClick={() => setFoo(foo() + 1)}>Increment foo</button>
        </>
    );
}
serban-mihai commented 2 weeks ago

Any update on this?