d******e 发帖数: 2265 | 1 React+Redux非常精炼,良好运用将发挥出极强劲的生产力。但最大的挑战来自于函数
式编程(FP)范式。在工程化过程中,架构(顶层)设计将是一个巨大的挑战。要不然
做出来的东西可能是一团乱麻。说到底,传统框架与react+redux就是OO与FP编程范式
的对决。
http://www.jianshu.com/p/0e42799be566
赶脚facebook和google两家人员还是有代狗的。
fb更加紧跟形势。狗家还是很传统,guava, angular,其实都是搞java oop的套路。f家
就更加fp话一点了。 | l**********n 发帖数: 8443 | 2 React.js pure render performance anti-pattern
https:[email protected]/* *//react-js-pure-render-performance-a
fb88c101332f#.xrfsamba5 | l**********n 发帖数: 8443 | 3 var ReactComponentWithPureRenderMixin = {
shouldComponentUpdate: function(nextProps, nextState) {
return !shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
}
}; | l**********n 发帖数: 8443 | 4 Why do we need pure functions, immutable data and virtual DOM? These are
optimizations and to some extent simplifications, not core to idea.
var root = document.getElementById('ui');
var prevState = state, prevTree = [];
function render(state) {
// Virtual DOM is really just a tree of JavaScript objects or arrays
return [
['span', {id: 'count'}, state.items.length],
['ul', {}, state.items.map(function (item) {
return ['li', {}, item]
})]
]
}
function updateUI() {
var vTree = render(state);
var diff = vDiff(prevTree, vTree); //Just a diff on data structures,
haha :)
vApply(root, diff) // Apply series of patches to real DOM
prevState = deepcopy(state);
prevTree = vTree;
} |
|