SKILL.md
$2a
Topic
Description
Reference
Subscriptions
Subscribe to state changes
Patch
Update state with patch operations
Signal
JSX component for inline reactive values
Store to State
Convert store to useState-like hooks
Features
Topic
Description
Reference
Plugin System
Extend stores with plugins
Persistent Plugin
Persist state to storage
Quick Start
import { defineStore, useStore } from 'valtio-define'
const store = defineStore({
state: () => ({ count: 0 }),
actions: {
increment() { this.count++ },
},
getters: {
doubled() { return this.count * 2 },
},
})
function Counter() {
const state = useStore(store)
return (
<div>
<div>Count: {state.count}</div>
<div>Doubled: {state.doubled}</div>
<button onClick={store.increment}>Increment</button>
</div>
)
}