Skip to content

Commit

Permalink
fix auto import error with whitespace JSXText (#11354)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaruan committed Apr 1, 2020
1 parent df819a0 commit 9444713
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
Expand Up @@ -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";
Expand Down
@@ -0,0 +1,5 @@
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
render() {
return <Text>&nbsp;{this.props.value}&nbsp;</Text>;
}
}
@@ -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>&nbsp;{this.props.value}&nbsp;</Text>;
}
}
@@ -0,0 +1,7 @@
/** @jsxRuntime classic */
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
render() {
return /*#__PURE__*/React.createElement(Text, null, "\xA0", this.props.value, "\xA0");
}

}
@@ -0,0 +1,7 @@
/** @jsxRuntime classic */

class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
render() {
return <Text>&nbsp;{this.props.value}&nbsp;</Text>;
}
}
@@ -0,0 +1,7 @@
/** @jsxRuntime classic */
class MobileHomeActivityTaskPriorityIcon extends React.PureComponent {
render() {
return /*#__PURE__*/React.createElement(Text, null, "\xA0", this.props.value, "\xA0");
}

}

0 comments on commit 9444713

Please sign in to comment.