我在这里遇到了这个配置https://github.com/developit/zero-to-preact/blob/master/webpack.config.js
plugins: [
['transform-react-jsx', { pragma: 'h' }]
]
文档说
pragma
string, defaults to React.createElement.
Replace the function used when compiling JSX expressions.
Note that the @jsx React.DOM pragma has been deprecated as of React v0.12
但不知道“h”是什么意思!这是什么?
最佳答案
默认情况下,babel 等将转换 <div id="hello" />
至 React.createElement("div", { id: "hello" });
. pragma: h
将生成为 h("div", { id: "hello" });
.
React.createElement
, (或 Preact 的 h
)是构建虚拟 DOM 的函数。
关于reactjs - transform-react-jsx 中的 "pragma h"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50629526/