storePath
Edit this pageimport { storePath } from "solid-js/store"
function storePath(...args: any[]): (draft: any) => voidstorePath() is a compatibility helper that adapts Solid 1.x-style path argument setters into a function you can pass to the Solid 2.0 draft-first setStore.
Usage
import { createStore } from "solid-js/store"import { storePath } from "solid-js/store"
const [store, setStore] = createStore({ user: { address: { city: "London" } }, items: ["a", "b", "c"],})
// 2.0 preferred: draft-first settersetStore((s) => { s.user.address.city = "Paris"})
// Optional compat: 1.x-style path setter via storePathsetStore(storePath("user", "address", "city", "Paris"))Path patterns
storePath supports the same patterns as Solid 1.x path setters:
Index access
setStore(storePath("items", 0, "newValue"))Range
setStore(storePath("items", { from: 1, to: 4, by: 2 }, 99))Filter
setStore(storePath("tasks", (task) => task.id === id, "completed", true))Delete sentinel
setStore(storePath("nickname", storePath.DELETE))When to use
Use storePath for gradual migration from Solid 1.x. For new code, prefer the draft-first setter pattern:
// PreferredsetStore((s) => { s.user.address.city = "Paris"})