首页/AI 前端工程/valtio-define
V

valtio-define

by @hairyfv
4.2(20)

掌握valtio-define的全面使用技巧,用于定义和管理Valtio状态。

valtioreact-state-managementproxy-based-statefrontend-developmentjavascript-librariesGitHub
安装方式
npx skills add hairyf/skills --skill valtio-define
compare_arrows

Before / After 效果对比

1
使用前

在使用Valtio进行状态管理时,若不熟悉其高级用法,可能导致状态定义混乱。代码可读性差,难以维护和扩展,影响开发效率。

使用后

运用此技能,能够全面掌握valtio-define的用法和最佳实践。优化状态定义,提升代码清晰度和可维护性,确保状态管理高效稳定。

SKILL.md

Based on valtio-define v1.0.1. A Valtio-based state management library with Pinia-like API for React applications.

Overview

valtio-define provides a factory function for creating reactive stores with state, actions, and getters. Built on top of Valtio, it offers a familiar API similar to Pinia with full TypeScript support.

Core References

TopicDescriptionReference
defineStoreCore API for creating reactive storescore-define-store
useStoreReact hook for accessing store statecore-use-store
TypesTypeScript types and interfacescore-types

Advanced Features

TopicDescriptionReference
SubscriptionsSubscribe to state changesadvanced-subscribe
PatchUpdate state with patch operationsadvanced-patch
SignalJSX component for inline reactive valuesadvanced-signal
Store to StateConvert store to useState-like hooksadvanced-store-to-state

Features

TopicDescriptionReference
Plugin SystemExtend stores with pluginsfeature-plugin-system
Persistent PluginPersist state to storagefeature-persistent-plugin

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>
  )
}

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量629
评分4.2 / 5.0
版本
更新日期2026年5月23日
对比案例1 组

用户评分

4.2(20)
5
15%
4
45%
3
35%
2
5%
1
0%

为此 Skill 评分

0.0

兼容平台

🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI

时间线

创建2026年3月16日
最后更新2026年5月23日