solid-js

How do you modify values in a solidjs store using a 2d array?


If I have a store like so...

  const [store, setStore] = createStore([
    [
      {
        foo: 1,
        bar: 'a',
      }
    ]
  ])

How would I update the value of foo (at [0][0]) to be 2 using setStore?


Solution

  • To update the value you use setStore like so...

    setStore(0, 0, 'foo', 2);