Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): honour import_source in new jsx #7128

Merged
merged 2 commits into from Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/swc_ecma_transforms_react/src/jsx/mod.rs
Expand Up @@ -993,7 +993,7 @@ where
src: Str {
span: DUMMY_SP,
raw: None,
value: "react".into(),
value: self.import_source.clone(),
}
.into(),
type_only: Default::default(),
Expand Down
@@ -0,0 +1,24 @@
import { isValidElement, Children } from "react";

import * as styles from "./CheckmarkList.styles";


const CheckmarkList = ({ children}) => {
const listItems = () =>
Children.map(children, (child, index) => {
if (!isValidElement(child)) {
return null;
}
const { children: liChildren, css: liCss, ...otherProps } = child.props;

return (
<li {...otherProps} key={`checkmark-list-item-${index}`} css={[styles.listItem, liCss]}>
{liChildren}
</li>
);
});

return <ul css={styles.list}>{listItems()}</ul>;
};

export { CheckmarkList };
@@ -0,0 +1,6 @@
{
"runtime": "automatic",
"importSource": "@emotion/react",
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment"
}
@@ -0,0 +1,25 @@
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { createElement as _createElement } from "@emotion/react";
import { isValidElement, Children } from "react";
import * as styles from "./CheckmarkList.styles";
const CheckmarkList = ({ children })=>{
const listItems = ()=>Children.map(children, (child, index)=>{
if (!/*#__PURE__*/ isValidElement(child)) {
return null;
}
const { children: liChildren , css: liCss , ...otherProps } = child.props;
return /*#__PURE__*/ _createElement("li", {
...otherProps,
key: `checkmark-list-item-${index}`,
css: [
styles.listItem,
liCss
]
}, liChildren);
});
return /*#__PURE__*/ _jsx("ul", {
css: styles.list,
children: listItems()
});
};
export { CheckmarkList };