S
SolidJS•13mo ago
PureSoul

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.
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
7 Replies
foolswisdom
foolswisdom•13mo ago
I think this is expected behavior. I think solid only merges the top level of the object you pass to set store, it doesn't merge recursively setStore("a", "b", {e: 4}) will merge, I think
PureSoul
PureSoul•13mo ago
why it remove the e key from top level store?
foolswisdom
foolswisdom•13mo ago
Oh, I see, it seems to be removing the "e" key from the top level 🤔. I don't think that's meant to be the behavior?
Otonashi
Otonashi•13mo ago
e isn't top level though? it's part of a the merging behaviour is shallow
foolswisdom
foolswisdom•13mo ago
Ah you're right. All the nesting confused me (and I was falling asleep 🙂)
PureSoul
PureSoul•12mo ago
Is it a bug?
foolswisdom
foolswisdom•12mo ago
No As explained here
Want results from more Discord servers?
Add your server
More Posts
Solit-start routing works for a bit after `run dev`, but then only shows 404. Why?After starting dev `npm run dev`, I get the overview: ``` ** ➜ Page Routes: ┌─ http://localhConditional fetching with createResourceHi! Alright, this might be a little bit silly but here's my problem: I have a context provider compoIs there a polyfills.ts for `solid-start`? Or is there a way of modyfing the produced `index.html` ?So, in the `aws amplify` framework there is a common bug, which all frameworks have to fix somehow: Pure client based page complaining about `window is not defined` in solid-start (No SSR needed)Back when I was just working with `solid.js` I could use `window` in my code just fine, for. pages tWhy does typescript not accept `text() && text().length === x` in solid-start?Is anyone aware why typescript complains about ```ts text() && text().length === 6 ``` in a projecUniversal renderer createElement isn't runningI'm working on a custom renderer and I can't get the createElement function to run. I'm not sure if How to read reactive state from imperative contexts (audio/music)**tl;dr:** is there any major DO NOT guideline around (constantly!) reading reactive states from fuHow to handle auto scrolling in a chat app when new message comes in?So this is an example what i currently have ```jsx const App = () => { const [messages, setMessageHow to get `onMount` to be called on the client for a server-rendered siteI've set up a new project using `solid-start` with `solid-start-aws`. Running `npm run build` createReactivity with normal functionsI try the following: `doubleCount` is using `createMemo` while `tripleCount` is a normal anonymous f