React源码

#1

通过实习项目接触react三个月左右,最近计划深入学习一下react源码,希望各位大佬分享一些react源码分析的资料以及github上值得学习的react开源项目

#2

同求!同求!

#3

自己以前整理的react 源代码阅读参考资料https://github.com/ihtml5/react-source。 推荐一个思路:可以在日常遇到问题的时候多搜下react的issues加深对某个概念的理解,比如setState等,然后再去参考别人的文章看源码。

#6

谢谢您,最近在看setState调用机制,有个地方没明白,“如 果 在 shouldComponentUpdate 或 componentWillUpdate 方 法 中 调 用 setState , 此 时this._pendingStateQueue != null,则 performUpdateIfNecessary 方法就会调用 updateComponent方法进行组件更新,但 updateComponent 方法又会调用 shouldComponentUpdate 和 componentWillUpdate 方法,因此造成循环调用,使得浏览器内存占满后崩溃”
这里如果在componentWillReceiveProps中setState不应该也会出现这种情况吗?还是说只有在shouldComponentUpdate 或 componentWillUpdate 方 法中才会去调用performUpdateIfNecessary 方法?

#7

最近找到一个比较好的博客可以看看,http://www.sosout.com/2018/08/12/react-source-analysis.html,这篇文章很好。看完可以自己开始分析源码了。

1 Like
#8

可以这么理解,shouldComponentUpdate 是每次组件更新都会触发的,而 componentWillReceiveProps 只是props改变才会触发,setState 并不会改变props的值

#9

:grin:好的

#10

推荐 fresh-concurrent-react, 在 Timeline.md 中汇集了相当丰富的 React 官方,非官方学习资料。学习源码我觉得应该注重整体的了解,而不是过分注意代码细节。
另外推荐一下自己的经验总结:learn-react