Cortex 是用来管理 React 深度嵌套结构的不可变数据存储。
主要特性:
支持深度嵌套数据
使用不可变数据,允许快速比较:shouldComponentUpdate
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']