SolidJSS
SolidJSโ€ข3y agoโ€ข
29 replies
zimo

Remove item from store list?

I have tried:
const itemId = 5;
setMainStore(
  "mylist",
  produce((mylist: number[] | undefined) =>
    mylist?.filter(item => item.id !== itemId.id
  )
)
console.log(mainStore.mylist!);


and

const itemId = 5;
setMainStore(
  "mylist",
  produce((mylist: number[] | undefined) =>
    mylist?.slice(mylist?.findIndex(item => item.id === itemId), 1)
  )
)
console.log(mainStore.mylist!);


but neither seem to change the list at all.
Was this page helpful?