Skip to content

Commit

Permalink
fix: forward ref to defaultStyle wrapped component
Browse files Browse the repository at this point in the history
  • Loading branch information
fnky committed Sep 12, 2022
1 parent 4fdfdd9 commit 6a3ac3c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/defaultStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import useStyles from 'substyle'

function createDefaultStyle(defaultStyle, getModifiers) {
const enhance = (ComponentToWrap) => {
const DefaultStyleEnhancer = ({
const DefaultStyleEnhancer = React.forwardRef(({
style,
className,
classNames,
...rest
}) => {
}, forwardedRef) => {
const modifiers = getModifiers ? getModifiers(rest) : undefined
const styles = useStyles(
defaultStyle,
{ style, className, classNames },
modifiers
)

return <ComponentToWrap {...rest} style={styles} />
}
return <ComponentToWrap {...rest} ref={forwardedRef} style={styles} />
})
const displayName =
ComponentToWrap.displayName || ComponentToWrap.name || 'Component'
DefaultStyleEnhancer.displayName = `defaultStyle(${displayName})`
Expand Down

0 comments on commit 6a3ac3c

Please sign in to comment.