Comments (4)
@gapsaras
问的很好,这个是React的一个难点,也是现在人都不怎么说的一个点。
如果facebook没有出jsx的话,我们用的就是createElement.js
书写React。
<div className='shit'>
asdasdasd
</div>
其实会被babel转换成
createElement('div',{className:'shit'},'asdasdasd')
在.babelrc中,你会看见
["transform-react-jsx", {
"pragma": "React.createElement" // 默认 pragma 为 React.createElement
}],
这一句话,这句话就是帮助babel找到createElement函数的地方。
createElement非常重要,也是生成Vnode的地方。
如果喜欢这个项目,给项目一些星星,近期将会有大更新,支持ComponentDidCatch,以及render返回任意的数据类型
from luy.
@215566435 谢谢大神的及时回复,我的理解是:createElement
会被babel使用,作为生成vnode的实现方法,相当于babel对外提供的一个可被用户覆盖的方法,不知是不是这样?
from luy.
@gapsaras 是的,没错。
from luy.
修复
from luy.
Related Issues (12)
- 虚拟dom算法 HOT 1
- React 16 架构学习资料 HOT 4
- READEME 错别字 HOT 1
- 事件无法绑定 <button onClick={this.updateNum.bind(this)}>点击修改Num</button>
- 看到这个fuck app蚌埠住了, 看来不止我这么无聊
- Ref会有泄漏,要删除
- 还在维护啊?赞!! HOT 1
- 按照示例运行出现错误 HOT 2
- 运行study报错? HOT 1
- 修正hascode初始化值
- Luy (React 16 以前) 架构 HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luy.