React Mug
React Mug 是一个简洁、函数式、贴合 React 组件化机制并拥有完善 Hook 集成的状态管理库。它通过类似马克杯的容器概念来盛装状态,提供简单直观的 API 来管理应用状态。
• Copy the embed code to showcase this product on your website
• Share on X to spread the word about this amazing tool
Sora Watermark Remover - Allows you to remove the watermark from Sora videos.Try Now
React Mug 是一个简洁、函数式、贴合 React 组件化机制并拥有完善 Hook 集成的状态管理库。它通过类似马克杯的容器概念来盛装状态,提供简单直观的 API 来管理应用状态。
• Copy the embed code to showcase this product on your website
• Share on X to spread the word about this amazing tool
0.1.0,用喜欢的包管理器安装就可以使用了,比如我喜欢直接用 npm:shnpm i react-mug下面我用一个 “加鱼” 的简单例子带大家快速感受一下。首先声明一个盛装 “鱼的数量” 状态的 Mug。所谓 Mug,就是马克杯的那个马克,而状态就是马克杯里的咖啡,声明一个 Mug 就拥有了一个盛装某个状态的容器,这里的状态便是 “鱼的数量”,[construction] 字段既表示了当前对象是一个 Mug 也设置了当前 Mug 里状态的初始值:tsximport { Mug, construction } from 'react-mug';const fishesMug: Mug<number> = { [construction]: 10,};然后创建一个 “加鱼” 的写操作器。加鱼顾名思义就是增加一条鱼 🐟:tsximport { w } from 'react-mug';const increment = w((n: number) => n + 1);之后分别创建 “展示鱼的数量” 和 “操控鱼的数量” 的两个 React 组件:tsximport { check, useOperator } from 'react-mug';function Fishes() { const fishes = useOperator(check, fishesMug); return <div>鱼的数量:{fishes}</div>;}function Controls() { return <button onClick={() => increment(fishesMug)}>加鱼</button>;}最后渲染这两个组件就可以在点击 “加鱼” 按钮的时候让 “鱼的数量” 加 1 了,除了以上代码不需要进行任何额外的配置。...Nano Banana AI Image Generator for Professional Image Creation with Nano Banana Pro Models
Create Cinematic AI Videos from Text or Images with Seedance 1.5
The Tatted AI Tattoo Generator is a tool that allows you to create beautiful custom tattoos within seconds.
Discover your PSL (Perceived Sexual Market Value) score with our AI-powered facial analysis
IPYNB to PDF Converter – Free & Secure