-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After refreshing the page, it shows the initial value #49
Comments
The code looks good. Maybe we have problem in Solid’s |
It returns the correct value by accessing 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>
<button class="button is-small" onClick={() => setFoo(foo() + 1)}>Increment foo</button>
</>
);
} |
Let’s create issue in |
It might be because
I think this line: Line 44 in 3ba73ff
Should be let store = atom(storageEngine[name] ? decode(storageEngine[name]) : initial); |
I see the same behavior in astro. import { useStore } from '@nanostores/preact'
import { text } from '../store';
export default function StoreInput() {
const $text = useStore(text);
console.log("text = ", $text);
function read() {
console.log("read ", $text)
return $text;
}
return (
<input
value={read()}
onInput={(e) => {
console.log("update")
text.set((e.target as HTMLInputElement).value)
}} />
)
} ( I added two instances of StoreInput to an astro page. Data is synchronized between them as expected. But when going to a different page and then coming back, the initial value is displayed. In the console, I can see that In astro, the component works as expected when using the |
I need somebody experienced in the framework for debug to find a reason. @tordeu can you do a investigation? |
@ai I am new to astro, but interested in finding the problem. But I will happily investigate as far as I am able to. I also created an issue for astro: withastro/astro#11401 |
As mentioned in withastro/astro#11401 (comment), I retested #49 (comment) using react and it is working as expected, now. |
The second step is wrong, after refreshing the page, it should display a number 5.
Don't know if I was using it correctly.
The text was updated successfully, but these errors were encountered: