核心功能
Base 包
适用于所有React环境的基础工具集
- 通用Hooks集合
- 类型工具和辅助函数
- 跨平台兼容的状态管理
DOM 包
专门为Web平台设计的工具集
- 浏览器相关的Hooks
- DOM操作辅助函数
- Web API封装
Native 包
为React Native开发优化的工具集
- 移动平台特定Hooks
- 原生组件辅助函数
- 跨平台数据同步
快速开始
安装
# 安装全部包
npm install wy-react-helper
# 或选择性安装
npm install @wy-react-helper/base
npm install @wy-react-helper/dom
npm install @wy-react-helper/native
基础使用
// 导入所需的hooks或工具函数
import { useLocalStorage } from 'wy-react-helper';
function MyComponent() {
// 使用hook
const [count, setCount] = useLocalStorage('count', 0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}