2作者: bosmarcel9 个月前
Hi HN 我开发了 *fluent-state*,一个轻量级的 React Hook,可以替代 useState、useReducer、useMemo 和 useEffect。 它能提供: - 流畅的、基于代理的 API:`state.user.name('Joe')` - 无需展开运算符的不可变更新 - 自动依赖项追踪 - 内置 `compute` 用于响应式、缓存的派生状态(无需 useMemo) - 内置 `effect` 用于响应式副作用,并自动进行依赖项追踪(无需 useEffect) - 零样板代码,完全掌控 专为本地状态、嵌套结构和简洁、声明式代码而设计。 演示:<a href="https:&#x2F;&#x2F;stackblitz.com&#x2F;edit&#x2F;vitejs-vite-uh4kyzkf?file=src%2FApp.tsx" rel="nofollow">https:&#x2F;&#x2F;stackblitz.com&#x2F;edit&#x2F;vitejs-vite-uh4kyzkf?file=src%2F...</a> GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;marsbos&#x2F;fluent-state">https:&#x2F;&#x2F;github.com&#x2F;marsbos&#x2F;fluent-state</a> NPM: <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;fluent-state" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;fluent-state</a> 请试用一下。