fix auto import error with whitespace JSXText (#11354)
This commit is contained in:
parent
df819a060c
commit
94447135c7
@ -303,12 +303,8 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
|
||||
"JSXElement|JSXFragment"(path) {
|
||||
if (path.type === "JSXFragment") imports.add("Fragment");
|
||||
const openingPath = path.get("openingElement");
|
||||
const validChildren = openingPath.parent.children.filter(
|
||||
child =>
|
||||
!t.isJSXEmptyExpression(child) &&
|
||||
!(t.isJSXText(child) && child.value.trim() === ""),
|
||||
);
|
||||
|
||||
const validChildren = t.react.buildChildren(openingPath.parent);
|
||||
let importName;
|
||||
if (path.type === "JSXElement" && shouldUseCreateElement(path)) {
|
||||
importName = "createElement";
|
||||
|
||||
5
packages/babel-plugin-transform-react-jsx/test/fixtures/nextReact/weird-symbols/input.js
vendored
Normal file
5
packages/babel-plugin-transform-react-jsx/test/fixtures/nextReact/weird-symbols/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
|
||||
render() {
|
||||
return <Text> {this.props.value} </Text>;
|
||||
}
|
||||
}
|
||||
10
packages/babel-plugin-transform-react-jsx/test/fixtures/nextReact/weird-symbols/output.mjs
vendored
Normal file
10
packages/babel-plugin-transform-react-jsx/test/fixtures/nextReact/weird-symbols/output.mjs
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { jsxs as _jsxs } from "react/jsx-runtime";
|
||||
|
||||
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
|
||||
render() {
|
||||
return /*#__PURE__*/_jsxs(Text, {
|
||||
children: ["\xA0", this.props.value, "\xA0"]
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
/** @jsxRuntime classic */
|
||||
|
||||
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
|
||||
render() {
|
||||
return <Text> {this.props.value} </Text>;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
/** @jsxRuntime classic */
|
||||
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
|
||||
render() {
|
||||
return /*#__PURE__*/React.createElement(Text, null, "\xA0", this.props.value, "\xA0");
|
||||
}
|
||||
|
||||
}
|
||||
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/weird-symbols/input.js
vendored
Normal file
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/weird-symbols/input.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/** @jsxRuntime classic */
|
||||
|
||||
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
|
||||
render() {
|
||||
return <Text> {this.props.value} </Text>;
|
||||
}
|
||||
}
|
||||
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/weird-symbols/output.js
vendored
Normal file
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/weird-symbols/output.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/** @jsxRuntime classic */
|
||||
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
|
||||
render() {
|
||||
return /*#__PURE__*/React.createElement(Text, null, "\xA0", this.props.value, "\xA0");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user