Skip to content

Commit

Permalink
fix(core-react): wrap button in forward ref (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgbenito7 authored and adamraider committed Aug 29, 2019
1 parent 89146c0 commit 031e1db
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/core-react/src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';

export default function Button({
Tag,
children,
type,
compact,
danger,
disabled,
className,
...props
}) {
const Button = React.forwardRef((props, ref) => {
const {
Tag,
children,
type,
compact,
danger,
disabled,
className,
...rest
} = props;
return (
<Tag
{...props}
{...rest}
className={clsx(
'ray-button',
`ray-button--${type}`,
Expand All @@ -25,11 +26,12 @@ export default function Button({
className
)}
disabled={disabled}
ref={ref}
>
{children}
</Tag>
);
}
});

Button.propTypes = {
type: PropTypes.oneOf(['primary', 'secondary', 'tertiary']),
Expand All @@ -47,3 +49,7 @@ Button.defaultProps = {
compact: false,
danger: false
};

Button.displayName = 'Button';

export default Button;

0 comments on commit 031e1db

Please sign in to comment.