-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 #6222 from Krustal/addon-info-forward-ref-opt-in
forwardRef elements use displayName if available
- Loading branch information
Showing
4 changed files
with
269 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
examples/official-storybook/components/ForwardedRefButtonWDisplayName.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,28 @@ | ||
import React, { forwardRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import BaseButton from './BaseButton'; | ||
|
||
const ForwardedRefButtonWDisplayName = forwardRef((props, ref) => ( | ||
<BaseButton {...props} forwardedRef={ref} /> | ||
)); | ||
|
||
ForwardedRefButtonWDisplayName.defaultProps = { | ||
disabled: false, | ||
onClick: () => {}, | ||
style: {}, | ||
}; | ||
|
||
ForwardedRefButtonWDisplayName.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({}), | ||
}; | ||
|
||
ForwardedRefButtonWDisplayName.displayName = 'ButtonDisplayName'; | ||
|
||
export default ForwardedRefButtonWDisplayName; |
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