Skip to content

Commit

Permalink
Merge pull request #80 from mrrs878/patch-1
Browse files Browse the repository at this point in the history
Update jsx.md
  • Loading branch information
BetaSu committed Jun 1, 2021
2 parents 62abf4f + adeeaeb commit e1981e6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/preparation/jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import React from 'react';
```
否则在运行时该模块内就会报`未定义变量 React`的错误。

::: warning 注意

在React17中,已经不需要显式导入React了。详见[介绍全新的 JSX 转换](https://zh-hans.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
:::

`JSX`并不是只能被编译为`React.createElement`方法,你可以通过[@babel/plugin-transform-react-jsx](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx)插件显式告诉`Babel`编译时需要将`JSX`编译为什么函数的调用(默认为`React.createElement`)。

Expand Down Expand Up @@ -183,4 +186,4 @@ ClassComponent.prototype.isReactComponent = {};

- [如何干掉知乎的全部DIV -- 通过这篇文章在运行时修改`React.createElement`达到消除页面所有`div`元素的效果](https://mp.weixin.qq.com/s/ICjOlJL-fUGRb2S_xqBT7Q)

- [React官网Blog,关于React Component, Element, Instance, Reconciliation的简介](https://reactjs.org/blog/2015/12/18/react-components-elements-and-instances.html)
- [React官网Blog,关于React Component, Element, Instance, Reconciliation的简介](https://reactjs.org/blog/2015/12/18/react-components-elements-and-instances.html)

0 comments on commit e1981e6

Please sign in to comment.