mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-21 05:02:39 +08:00
render the displayName for the component name if a forwardRef element provides it. Resolves #5974
29 lines
774 B
JavaScript
29 lines
774 B
JavaScript
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;
|