Skip to content
Permalink
Browse files

feat(core-button): add forwardRef

  • Loading branch information...
agorovyi authored and jraff committed Jun 11, 2019
1 parent e447c9c commit fd8f181ad20261e821615a87fe3a3f7fc40f72cb
Showing with 6 additions and 4 deletions.
  1. +6 −4 packages/Button/Button.jsx
@@ -1,4 +1,4 @@
import React from 'react'
import React, { forwardRef } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'

@@ -84,15 +84,17 @@ export const ButtonTextWrapper = styled.span({
/**
* @version ./package.json
*/
const Button = ({ type, variant, children, ...rest }) => {
const Button = forwardRef(({ type, variant, children, ...rest }, ref) => {
const restNoDisabled = preventDisabling(rest)

return (
<StyledButton {...safeRest(restNoDisabled)} variant={variant} type={type}>
<StyledButton {...safeRest(restNoDisabled)} variant={variant} type={type} ref={ref}>
<ButtonTextWrapper>{children}</ButtonTextWrapper>
</StyledButton>
)
}
})

Button.displayName = 'Button'

Button.propTypes = {
/**

0 comments on commit fd8f181

Please sign in to comment.
You can’t perform that action at this time.