此项目借助 babel 实现一个简单的 React,参考了这个系列,使用 parcel 打包,React 版本是 v15,跟目前的 v16 有一定区别,只是为了学习 React 原理而练习的。
- JSX 与虚拟 DOM:实现
React.createElement和ReactDOM.render
- 组件和生命周期方法:实现
Component类, 和renderComponent
- diff 算法:tree diff, component diff, children diff
- setState 异步处理:队列机制
<iframe
src="https://codesandbox.io/embed/blue-monad-jt13f?fontsize=14&hidenavigation=1&theme=dark"
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
title="my-simple-react"
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
></iframe>