PureSoul
PureSoul
SSolidJS
Created by PureSoul on 4/28/2025 in #support
why store not updated in createAsync?
import { createStore } from "solid-js/store";
import { createAsync } from "solid-js";

export default function Demo() {
const [user, setUser] = createStore({ name: "Initial", age: 0 });

const data = createAsync(async () => {
console.log("Start async", user);

setUser({ name: "Changed", age: 99 });
console.log("After setUser, user:", user);

await new Promise((r) => setTimeout(r, 2000));

console.log("After 2s, user:", user);

return "done";
}, { deferStream: true });

return (
<div>
<h1>User Name: {user.name}</h1> {/* ❓ */}
<h2>User Age: {user.age}</h2> {/* ❓ */}
<h3>Data: {data()}</h3>
</div>
);
}
import { createStore } from "solid-js/store";
import { createAsync } from "solid-js";

export default function Demo() {
const [user, setUser] = createStore({ name: "Initial", age: 0 });

const data = createAsync(async () => {
console.log("Start async", user);

setUser({ name: "Changed", age: 99 });
console.log("After setUser, user:", user);

await new Promise((r) => setTimeout(r, 2000));

console.log("After 2s, user:", user);

return "done";
}, { deferStream: true });

return (
<div>
<h1>User Name: {user.name}</h1> {/* ❓ */}
<h2>User Age: {user.age}</h2> {/* ❓ */}
<h3>Data: {data()}</h3>
</div>
);
}
I update store in createAsync, but why it not updated in JSX?
6 replies
SSolidJS
Created by PureSoul on 4/28/2025 in #support
when in createAsync with deferStream, if I update state, it not immediatly updating createMemo.
// ExampleSolidAsync.tsx
import { createSignal, createMemo, createAsync } from "solid-js";

export default function ExampleSolidAsync() {
const [count, setCount] = createSignal(0);

const doubled = createMemo(() => {
console.log("Memo re-running, count:", count());
return count() * 2;
});

const asyncData = createAsync(async () => {
console.log("Before setCount, count:", count(), "doubled:", doubled());

setCount(10); // updating count
console.log("After setCount, count:", count(), "doubled:", doubled());

await Promise.resolve();
console.log("After await Promise.resolve(), count:", count(), "doubled:", doubled());

await new Promise((r) => setTimeout(r, 1000));
console.log("After 1 second, count:", count(), "doubled:", doubled());

return "done";
});

return (
<div>
<h1>Count: {count()}</h1>
<h2>Doubled: {doubled()}</h2>
<h3>Async result: {asyncData()}</h3>
</div>
);
}
// ExampleSolidAsync.tsx
import { createSignal, createMemo, createAsync } from "solid-js";

export default function ExampleSolidAsync() {
const [count, setCount] = createSignal(0);

const doubled = createMemo(() => {
console.log("Memo re-running, count:", count());
return count() * 2;
});

const asyncData = createAsync(async () => {
console.log("Before setCount, count:", count(), "doubled:", doubled());

setCount(10); // updating count
console.log("After setCount, count:", count(), "doubled:", doubled());

await Promise.resolve();
console.log("After await Promise.resolve(), count:", count(), "doubled:", doubled());

await new Promise((r) => setTimeout(r, 1000));
console.log("After 1 second, count:", count(), "doubled:", doubled());

return "done";
});

return (
<div>
<h1>Count: {count()}</h1>
<h2>Doubled: {doubled()}</h2>
<h3>Async result: {asyncData()}</h3>
</div>
);
}
1 replies
SSolidJS
Created by PureSoul on 4/15/2025 in #support
Cannot read properties of null (reading '1')Cannot read properties of null (reading '1')
No description
1 replies
SSolidJS
Created by PureSoul on 6/2/2023 in #support
setStore function replace object value
https://playground.solidjs.com/anonymous/f0b1602b-24a8-48db-a37d-e60db6eb3f85
function Counter() {
const [store, setStore] = createStore({
a: { b: { c: 2, d: 3 }, e: { f: { g: 4, h: 5 } } },
});
setStore({ a: { b: { e: 4 } } });
console.log(JSON.stringify(store));

return <div>Test</div>;
}
function Counter() {
const [store, setStore] = createStore({
a: { b: { c: 2, d: 3 }, e: { f: { g: 4, h: 5 } } },
});
setStore({ a: { b: { e: 4 } } });
console.log(JSON.stringify(store));

return <div>Test</div>;
}
In this example setStore is replacing whole store, instead it should merge the store.
12 replies
SSolidJS
Created by PureSoul on 5/9/2023 in #support
CreateStore types not work for array
const [store, setStore] = createStore([{
lotNumber: '',
}]);
const [store, setStore] = createStore([{
lotNumber: '',
}]);
This is giving typescript error in v1.7.5
4 replies
SSolidJS
Created by PureSoul on 4/25/2023 in #support
Cant Change Store with unwrap
when I first unwrap the store and then I set the value its not updated: reproducible example: https://playground.solidjs.com/anonymous/650e10ae-8881-43d4-b1ff-7478e1a1c894
8 replies
SSolidJS
Created by PureSoul on 3/10/2023 in #support
How to add calculated getter in a existing store?
const [store, setStore] = createStore({firstName: "Foo", lastName: "Bar"})
15 replies