V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
LeoooY
V2EX  ›  React

用 React hooks api 封装一个 React 状态管理库

  •  1
     
  •   LeoooY ·
    LeoooY · 2020-05-22 18:38:52 +08:00 · 2195 次点击
    这是一个创建于 1427 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用 React hooks api 封装了一个 React 状态管理库,求各位带佬的 star 和 pr 。
    github: https://github.com/LeoooY/eoxgithub.com/LeoooY/eox
    doc: https://leoooy.github.io/eoxdoc/leoooy.github.io/eoxdoc


    文档是用 facebook 的 docusaurus 写的,很香~: https://github.com/facebook/docusaurus
    5 条回复    2020-05-26 10:54:30 +08:00
    LeoooY
        1
    LeoooY  
    OP
       2020-05-24 21:24:40 +08:00
    theprimone
        2
    theprimone  
       2020-05-25 09:09:20 +08:00
    我还是用 dva 吧 [手动滑稽]
    LeoooY
        3
    LeoooY  
    OP
       2020-05-25 10:45:56 +08:00
    @theprimone 复杂项目还是会用 redux 或者 dva,就是想搞个简单、快速的适合小型项目的状态管理,大佬有没啥想法来个 pr 哇
    theprimone
        4
    theprimone  
       2020-05-26 09:01:29 +08:00
    简单的 useState 和 useReducer 不就够用了吗?另外异步逻辑现在我都基本使用 @umijs/hooks 的 useRequest 来封装了。
    LeoooY
        5
    LeoooY  
    OP
       2020-05-26 10:54:30 +08:00
    @theprimone 就是把 useReducer 和 useContext 封装了一下,另外做了个类似于 redux 的 mapStateToProp 的 withContext 来优化 context 更新导致的 re-render
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4062 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 05:22 · PVG 13:22 · LAX 22:22 · JFK 01:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.