purplebamboo / blog

purplebamboo的博客

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react源码分析下

shadowQiao opened this issue · comments

发布在 http://purplebamboo.github.io/2015/09/15/reactjs_source_analyze_part_two/ 写得非常好,但是存在两个问题

  1. ReactCompositeComponent.prototype.receiveComponent方法没有更新实例的属性,需要在inst.state = nextState;下面添加上
    inst.props = nextProps;
    2.第一种没有lastIndex的diff方法和patch方法存在逻辑错误。diff方法相当于给所有参与diff的节点都分配了删除操作,在patch方法里先执行了所有的删除操作,那么也就是说后续的插入操作会找不到插入的父节点位置。