mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Refactor Button and Header components to use not use React's defaultProps
This commit is contained in:
parent
0203747b08
commit
9e94c25f69
@ -5,7 +5,13 @@ import PropTypes from 'prop-types';
|
||||
import './button.css';
|
||||
|
||||
/** Primary UI component for user interaction */
|
||||
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
|
||||
export const Button = ({
|
||||
primary = false,
|
||||
backgroundColor = null,
|
||||
size = 'medium',
|
||||
label,
|
||||
...props
|
||||
}) => {
|
||||
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
||||
return (
|
||||
<button
|
||||
@ -31,10 +37,3 @@ Button.propTypes = {
|
||||
/** Optional click handler */
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
|
||||
Button.defaultProps = {
|
||||
backgroundColor: null,
|
||||
primary: false,
|
||||
size: 'medium',
|
||||
onClick: undefined,
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
||||
import { Button } from './Button';
|
||||
import './header.css';
|
||||
|
||||
export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
|
||||
export const Header = ({ user = null, onLogin, onLogout, onCreateAccount }) => (
|
||||
<header>
|
||||
<div className="storybook-header">
|
||||
<div>
|
||||
@ -54,7 +54,3 @@ Header.propTypes = {
|
||||
onLogout: PropTypes.func.isRequired,
|
||||
onCreateAccount: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
Header.defaultProps = {
|
||||
user: null,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user