Loading...
Loading...
TanStack Store for framework-agnostic reactive state management with derived state and batching. Use when managing shared state, creating derived computations, or building framework-agnostic state logic. Use for tanstack-store, store, state, derived, batch, subscribe, reactive-state.
npx skill4agent add oakoss/agent-skills tanstack-storesetStatesetState| Package | Use Case |
|---|---|
| Framework-agnostic core |
| React adapter (re-exports core) |
| Vue adapter |
| Solid adapter |
| Angular adapter |
| Svelte adapter |
StoreDerivedEffectbatch| Pattern | API | Key Points |
|---|---|---|
| Create store | | Generic over |
| Read state | | Synchronous property access |
| Previous state | | Value before last |
| Update state | | Accepts updater function or direct value |
| Subscribe | | Returns unsubscribe function |
| Derived value | | Lazily recomputes when dependencies change |
| Mount derived | | Required to activate dependency tracking |
| Derived from derived | Nest | Forms a computation graph |
| Batch updates | | Subscribers notified once after all updates |
| Side effects | | Runs fn when dependencies change |
| Mount effect | | Required to start listening |
| React binding | | Re-renders only when selected value changes |
| Shallow compare | | Prevents re-renders for structurally equal objects |
| Lifecycle: subscribe | | Fires on first subscriber, cleanup on last |
| Lifecycle: update | | Fires after every state change |
| Custom updater | | Replace default setState behavior |
| Previous deps | | Compare current vs previous dependency values |
| Dep vals access | | Array ordered by |
| Mistake | Correct Pattern |
|---|---|
Reading | Call |
| Forgetting to unmount derived/effect | Store the cleanup function and call it on teardown |
Multiple | Wrap related updates in |
Selecting objects in | Pass |
| Mutating state object directly | Always return a new object from |
| Subscribing inside render without cleanup | Use |
| Creating stores inside React components | Instantiate stores outside components or in a ref/useState |
| Not including all deps in Derived | List every Store/Derived dependency in the |
| Mounting Derived deps after the parent | Mount leaf dependencies before parent Derived values |
Using | Install |
tanstack-querynpx skills add oakoss/agent-skills --skill tanstack-querytanstack-formnpx skills add oakoss/agent-skills --skill tanstack-formExplorecode-reviewer