-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4961 from yjcxy12/addon-info-forward-ref
add forwardRef support to addon-info
- Loading branch information
Showing
6 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
examples/official-storybook/components/ForwardedRefButton.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { forwardRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import BaseButton from './BaseButton'; | ||
|
||
const ForwardedRefButton = forwardRef((props, ref) => <BaseButton {...props} forwardedRef={ref} />); | ||
|
||
ForwardedRefButton.defaultProps = { | ||
disabled: false, | ||
onClick: () => {}, | ||
style: {}, | ||
}; | ||
|
||
ForwardedRefButton.propTypes = { | ||
/** Boolean indicating whether the button should render as disabled */ | ||
disabled: PropTypes.bool, | ||
/** button label. */ | ||
label: PropTypes.string.isRequired, | ||
/** onClick handler */ | ||
onClick: PropTypes.func, | ||
/** Custom styles */ | ||
style: PropTypes.shape({}), | ||
}; | ||
|
||
export default ForwardedRefButton; |
Oops, something went wrong.