Skip to content

Commit

Permalink
fix(emotion): support ReactTestUtils in decorators that use forwardRef
Browse files Browse the repository at this point in the history
  • Loading branch information
balzss committed Oct 18, 2023
1 parent 4aed81e commit c7389cb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/emotion/src/withStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const withStyle = decorator(
> & {
generateComponentTheme?: GenerateComponentTheme
allowedProps?: string[]
originalType?: WithStyleComponent
} = forwardRef((props, ref) => {
const theme = useTheme()

Expand Down Expand Up @@ -243,6 +244,10 @@ const withStyle = decorator(

hoistNonReactStatics(WithStyle, ComposedComponent)

// workaround so this can be tested with ReactTestUtils
// more info: https://github.com/facebook/react/issues/13455
WithStyle.originalType = ComposedComponent

// we have to pass these on, because sometimes users
// access propTypes of the component in other components
// eslint-disable-next-line react/forbid-foreign-prop-types
Expand Down

0 comments on commit c7389cb

Please sign in to comment.