爱意满满的作品展示区。
yzhen123

nstate: 一个轻量级+低心智负担的 React 状态管理库

  •  
  •   yzhen123 · Oct 18, 2021 · 2965 views
    This topic created in 1851 days ago, the information mentioned may be changed or developed.

    特性:

    1. 极简 API + 良好的 TS 支持
    2. 内置 immer 简化深层状态更新
    3. 自动绑定 action 方法
    4. 支持多 store 相互组合复用
    5. 支持监听状态变化

    Counter demo:

    repo: https://github.com/zaaack/nstate

    6 replies  •  2021-10-19 11:16:37 +08:00
    Lanayaaa
    Lanayaaa
    Oct 18, 2021
    1
    有类似 vue 的 computed 值吗?
    yzhen123
    yzhen123
    OP
    Oct 18, 2021
    2
    @PainAndLove 没有,但是有 .useState 可以实现类似功能
    cyberpoint
    cyberpoint
    Oct 18, 2021
    3
    redux-toolkit 挺好用的
    Lanayaaa
    Lanayaaa
    Oct 19, 2021
    4
    @yzhen123 还是不太方便。 如果在多个组件里用,每个组件里都得重复写。
    yzhen123
    yzhen123
    OP
    Oct 19, 2021
    5
    @PainAndLove 可以封装成 Store 上的方法,

    ```ts
    class Store extends NState {
    useCount() {

    }
    }
    ```
    yzhen123
    yzhen123
    OP
    Oct 19, 2021
    6
    @PainAndLove 可以封装成 Store 上的方法,

    ```ts
    class Store extends NState {
    useCount() {
    return this.useState(s => s.count + 1)
    }
    }
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:13 · PVG 06:13 · LAX 14:13 · JFK 17:13
    ♥ Do have faith in what you're doing.