refactor: add pragmaFrag config

This commit is contained in:
dntzhang 2019-10-05 07:49:17 +08:00
parent 10caee7380
commit 6e718c0ae6
3 changed files with 13 additions and 7 deletions

View File

@ -148,7 +148,9 @@ module.exports = {
[
"@babel/preset-react",
{
"pragma": "h"
"pragma": "Preact.h", // default pragma is React.createElement
"pragmaFrag": "Preact.Fragment", // default is React.Fragment
"throwIfNamespace": false // defaults to true
}
]
],

View File

@ -182,7 +182,9 @@ module.exports = {
[
"@babel/preset-react",
{
"pragma": "h"
"pragma": "Preact.h", // default pragma is React.createElement
"pragmaFrag": "Preact.Fragment", // default is React.Fragment
"throwIfNamespace": false // defaults to true
}
]
],

View File

@ -1,14 +1,16 @@
import { render, h } from 'preact'
import * as Preact from 'preact'
import './preact-css'
function Counter() {
return (
<div>Hello Preact X</div>
<>
<div>Hello Preact X</div>
<div>Hello Preact CSS</div>
</>
)
}
render(<Counter />, document.querySelector('#root'))
Preact.render(<Counter />, document.querySelector('#root'))