Skip to content

Commit fd53e77

Browse files
authored
Ignore React Fragments (#1)
There is no way to add a data-component attribute to a fragment, and this plugin skipped the fragment ad added the data-component attribute to the children of the fragment. This commit ignores fragments when they are the return statement and does not require a data component.
1 parent eb35669 commit fd53e77

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ function isTreeDone(node, excludeComponentNames) {
6464

6565
function isSubtreeDone(node) {
6666
return (
67-
node.type === 'JSXElement' &&
68-
node.openingElement.attributes.find(
69-
(attributeNode) => attributeNode.name?.name === 'data-component',
70-
)
67+
node.type === 'JSXFragment' ||
68+
(node.type === 'JSXElement' &&
69+
node.openingElement.attributes.find(
70+
(attributeNode) => attributeNode.name?.name === 'data-component',
71+
))
7172
);
7273
}
7374

0 commit comments

Comments
 (0)