zustand by vercel-labs/json-render
npx skills add https://github.com/vercel-labs/json-render --skill zustand用于 json-render StateStore 接口的 Zustand 适配器。将 Zustand 原生存储作为 json-render 的状态后端。
npm install @json-render/zustand @json-render/core @json-render/react zustand
需要 Zustand v5+。由于原生存储接口存在破坏性 API 变更,不支持 Zustand v4。
import { createStore } from "zustand/vanilla";
import { zustandStateStore } from "@json-render/zustand";
import { StateProvider } from "@json-render/react";
// 1. 创建一个 Zustand 原生存储
const bearStore = createStore(() => ({
count: 0,
name: "Bear",
}));
// 2. 创建 json-render 的 StateStore 适配器
const store = zustandStateStore({ store: bearStore });
// 3. 使用它
<StateProvider store={store}>
{/* json-render 的读写操作将通过 Zustand 进行 */}
</StateProvider>
const appStore = createStore(() => ({
ui: { count: 0 },
auth: { token: null },
}));
const store = zustandStateStore({
store: appStore,
selector: (s) => s.ui,
updater: (next, s) => s.setState({ ui: next }),
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
zustandStateStore(options)创建一个由 Zustand 存储支持的 StateStore。
| 选项 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
store | StoreApi<S> | 是 | Zustand 原生存储(来自 zustand/vanilla 中的 createStore) |
selector | (state) => StateModel | 否 | 选择 json-render 的切片。默认为整个状态。 |
updater | (nextState, store) => void | 否 | 将下一个状态应用到存储。默认为浅合并。对于嵌套切片,请重写此方法,或使用 (next, s) => s.setState(next, true) 进行完全替换。 |
每周安装量
257
代码仓库
GitHub 星标数
13.3K
首次出现
2026年3月7日
安全审计
安装于
codex251
github-copilot248
cursor248
kimi-cli247
gemini-cli247
amp247
Zustand adapter for json-render's StateStore interface. Wire a Zustand vanilla store as the state backend for json-render.
npm install @json-render/zustand @json-render/core @json-render/react zustand
Requires Zustand v5+. Zustand v4 is not supported due to breaking API changes in the vanilla store interface.
import { createStore } from "zustand/vanilla";
import { zustandStateStore } from "@json-render/zustand";
import { StateProvider } from "@json-render/react";
// 1. Create a Zustand vanilla store
const bearStore = createStore(() => ({
count: 0,
name: "Bear",
}));
// 2. Create the json-render StateStore adapter
const store = zustandStateStore({ store: bearStore });
// 3. Use it
<StateProvider store={store}>
{/* json-render reads/writes go through Zustand */}
</StateProvider>
const appStore = createStore(() => ({
ui: { count: 0 },
auth: { token: null },
}));
const store = zustandStateStore({
store: appStore,
selector: (s) => s.ui,
updater: (next, s) => s.setState({ ui: next }),
});
zustandStateStore(options)Creates a StateStore backed by a Zustand store.
| Option | Type | Required | Description |
|---|---|---|---|
store | StoreApi<S> | Yes | Zustand vanilla store (from createStore in zustand/vanilla) |
selector | (state) => StateModel | No | Select the json-render slice. Defaults to entire state. |
updater |
Weekly Installs
257
Repository
GitHub Stars
13.3K
First Seen
Mar 7, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex251
github-copilot248
cursor248
kimi-cli247
gemini-cli247
amp247
Flutter应用架构设计指南:分层结构、数据层实现与最佳实践
3,400 周安装
(nextState, store) => void |
| No |
Apply next state to the store. Defaults to shallow merge. Override for nested slices, or use (next, s) => s.setState(next, true) for full replacement. |