Skip to content

Commit

Permalink
fix: isReactNode should check jsx too (not just jsxDEV) (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
peetck authored Feb 21, 2024
1 parent b153a4a commit 7e7cc24
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/magicString/react/isReactNode/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export default function isReactNode(node: Record<string, any>) {
return (
(node?.callee?.object?.name === 'React' && node?.callee?.property?.name === 'createElement') ||
(node?.callee?.name === 'jsxDEV' && node.arguments?.[0]?.name !== 'Fragment')
)
const isReactCreateElement =
node?.callee?.object?.name === 'React' && node?.callee?.property?.name === 'createElement'

const isJsxAndNotFragment =
(node?.callee?.name === 'jsxDEV' || node?.callee?.name === 'jsx') &&
node?.arguments?.[0]?.name !== 'Fragment'

return isReactCreateElement || isJsxAndNotFragment
}

0 comments on commit 7e7cc24

Please sign in to comment.