Skip to content

Commit

Permalink
refactor(core): add forward refs to base components
Browse files Browse the repository at this point in the history
BREAKING CHANGE: base components can hold a ref.
  • Loading branch information
varl committed Mar 23, 2020
1 parent 2207bf2 commit 699b194
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions packages/core/src/ButtonBase/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,40 @@ import styles from './ButtonBase.styles.js'
* @param {ButtonBase.PropTypes} props
* @returns {React.Component}
*/
export const ButtonBase = ({
children,
className,
primary,
secondary,
destructive,
small,
large,
disabled,
...props
}) => (
<button
{...props}
className={cx(className, {
function ButtonBase(
{
children,
className,
primary,
secondary,
destructive,
small,
large,
})}
disabled={disabled}
>
{children}
<style jsx>{styles}</style>
</button>
)
disabled,
...props
},
ref
) {
return (
<button
{...props}
className={cx(className, {
primary,
secondary,
destructive,
small,
large,
})}
disabled={disabled}
ref={ref}
>
{children}
<style jsx>{styles}</style>
</button>
)
}

export default React.forwardRef(ButtonBase)

/**
* @typedef {Object} PropTypes
Expand Down

0 comments on commit 699b194

Please sign in to comment.