S
SolidJS•4mo ago
binajmen

Are store reactive?

const [params, setParams] = createStore<Params>(
props.value ?? {
data: [
{ points: 100, requirement: 10 },
{ points: 50, requirement: 5 },
{ points: 0, requirement: 0 },
],
},
);

createEffect(() => {
console.log(params.data.at(0));
});
const [params, setParams] = createStore<Params>(
props.value ?? {
data: [
{ points: 100, requirement: 10 },
{ points: 50, requirement: 5 },
{ points: 0, requirement: 0 },
],
},
);

createEffect(() => {
console.log(params.data.at(0));
});
It consoles several time at rendering, but when modifying the values no more logs
12 Replies
binajmen
binajmen•4mo ago
I reviewed the doc https://docs.solidjs.com/concepts/stores#accessing-store-values I have a repro here https://stackblitz.com/edit/solidjs-templates-qaqznn?file=src%2FApp.tsx it shows when adding or removing an element, not when editing the content
bigmistqke 🌈
bigmistqke 🌈•4mo ago
Mb .at is not reactive? params.data[0] should work.
binajmen
binajmen•4mo ago
to be honest I was expectinghoping this to log:
createEffect(() => {
console.log(params.data);
});
createEffect(() => {
console.log(params.data);
});
bigmistqke 🌈
bigmistqke 🌈•4mo ago
That wouldn't be finegrained
binajmen
binajmen•4mo ago
*was hoping
bigmistqke 🌈
bigmistqke 🌈•4mo ago
There is a deep tracking utility in solid-primitives Iirc
binajmen
binajmen•4mo ago
createMutable?
bigmistqke 🌈
bigmistqke 🌈•4mo ago
Solid Primitives
A library of high-quality primitives that extend SolidJS reactivity
binajmen
binajmen•4mo ago
I will have a look thanks i am wondering though what is the purpose of stores if not tracking nested info
Alex Lohr
Alex Lohr•4mo ago
They are tracking nested info, but only the leaves, not the branches.
bigmistqke 🌈
bigmistqke 🌈•4mo ago
Otherwise createEffect(() => store[0]) would also be called when store[1] changes
binajmen
binajmen•4mo ago
ok it makes sense