diff options
| author | haishanh <[email protected]> | 2018-11-05 18:32:16 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2018-11-06 22:37:21 +0800 |
| commit | 91ecdaa5dd1a65ff0ae944896945c0fe4bc23574 (patch) | |
| tree | 9f7f476672fae91eca5df9e0ae021b45df950679 /src/components/Button.js | |
| parent | 1adaedcbc551f6beee4e9e0b9fbd94197ebdffe5 (diff) | |
update: convert more components to function ones
includes Input, Config, SideBard.
also removed react-redux Provider
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; |
