diff options
Diffstat (limited to 'src/components/Button.js')
| -rw-r--r-- | src/components/Button.js | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/components/Button.js b/src/components/Button.js index 34fe5fe..eb50ffd 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -1,25 +1,20 @@ -import React, { Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import s0 from 'c/Button.module.scss'; +const noop = () => {}; -class Button extends Component { - static propTypes = { - label: PropTypes.string.isRequired, - onClick: PropTypes.func - }; +const Button = React.memo(function Button({ label, onClick = noop }) { + return ( + <button className={s0.btn} onClick={onClick}> + {label} + </button> + ); +}); - static defaultProps = { - onClick: () => {} - }; - - render() { - return ( - <button className={s0.btn} onClick={this.props.onClick}> - {this.props.label} - </button> - ); - } -} +Button.propTypes = { + label: PropTypes.string.isRequired, + onClick: PropTypes.func +}; export default Button; |
