CortexReact 不可变数据存储

联合创作 · 2023-09-22 05:54

Cortex 是用来管理 React 深度嵌套结构的不可变数据存储。


主要特性:



  • 支持深度嵌套数据


  • 使用不可变数据,允许快速比较:shouldComponentUpdate


  • 高效的分支更新


  • 简单 APIs


  • 轻量级  (4.5kB minified and gzip)


  • 使用 ES6 编写



示例


skyline (4-level nested components)


file system (arbitrarily deep structure of a single component type)


快速开始


初始化 cortex 对象



var data = {a: 100, b: [1, 2, 3]};
var cortex = new Cortex(data, function(updatedCortex) {
  //trigger React component to update props
  myComponent.setProps({cortex: updatedCortex});
});

获取一个嵌套 cortex 对象



cortex.a

//Also works
cortex['a']
浏览 15
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报