solidjs-community/solid-primitives

Can't add new keys to persisted stores - feature request for different defaults handing

Open

#748 opened on Feb 8, 2025

 (9 comments) (0 reactions) (1 assignee)TypeScript (153 forks)auto 404
help wanted

Repository metrics

Stars
 (1,541 stars)
PR merge metrics
 (PR metrics pending)

Description

Describe the bug

  const [,setStore] = makePersisted(createStore({a: 1}), {name: 'x'})
  setStore({a: 2}) // trigger storage (because initial values are not persisted)
  const [store2, setStore2] = makePersisted(createStore({a: 1, b: 1}), {name: 'x'})
  console.log(Object.keys(store2)) // ['a']

I would expect ['a', 'b']

While I'm here: these stores are so useful and convenient! Thanks for this.

Minimal Reproduction Link

https://stackblitz.com/edit/github-cickt7r1?file=src%2Findex.tsx

Contributor guide