Skip to content

Commit

Permalink
fix(button): use JSX instead of createElement
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Jun 10, 2024
1 parent dc73633 commit d1f5648
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/core/primitives/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createElement, forwardRef, isValidElement, useMemo} from 'react'
import {forwardRef, isValidElement, useMemo} from 'react'
import {isValidElementType} from 'react-is'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
Expand Down Expand Up @@ -68,8 +68,8 @@ export const Button = forwardRef(function Button(
children,
disabled,
fontSize = 1,
icon,
iconRight,
icon: IconComponent,
iconRight: IconRightComponent,
justify: justifyProp = 'center',
loading,
mode = 'default',
Expand Down Expand Up @@ -138,13 +138,13 @@ export const Button = forwardRef(function Button(
</LoadingBox>
)}

{(icon || text || iconRight) && (
{(IconComponent || text || IconRightComponent) && (
<Box as="span" {...boxProps}>
<Flex as="span" justify={justify} gap={space}>
{icon && (
{IconComponent && (
<Text size={fontSize}>
{isValidElement(icon) && icon}
{isValidElementType(icon) && createElement(icon)}
{isValidElement(IconComponent) && IconComponent}
{isValidElementType(IconComponent) && <IconComponent />}
</Text>
)}

Expand All @@ -160,10 +160,10 @@ export const Button = forwardRef(function Button(
</Text>
)}

{iconRight && (
{IconRightComponent && (
<Text size={fontSize}>
{isValidElement(iconRight) && iconRight}
{isValidElementType(iconRight) && createElement(iconRight)}
{isValidElement(IconRightComponent) && IconRightComponent}
{isValidElementType(IconRightComponent) && <IconRightComponent />}
</Text>
)}
</Flex>
Expand Down

0 comments on commit d1f5648

Please sign in to comment.