Skip to content

Commit 6a68d46

Browse files
committed
Simplify underlying Button component
1 parent 35db0c5 commit 6a68d46

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

src/js/Button.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33

4-
class Button extends React.PureComponent {
5-
static propTypes = {
6-
children: PropTypes.node.isRequired,
7-
title: PropTypes.string,
8-
};
4+
const propTypes = {
5+
children: PropTypes.node.isRequired,
6+
title: PropTypes.string,
7+
};
8+
const defaultProps = {
9+
title: null,
10+
};
911

10-
static defaultProps = {
11-
title: null,
12-
};
13-
14-
render() {
15-
const { children, title, ...props } = this.props;
16-
17-
return (
18-
<button
19-
aria-label={title}
20-
title={title}
21-
type="button"
22-
{...props}
23-
>
24-
{children}
25-
</button>
26-
);
27-
}
12+
function Button({ children, title, ...props }) {
13+
return (
14+
<button
15+
aria-label={title}
16+
title={title}
17+
type="button"
18+
{...props}
19+
>
20+
{children}
21+
</button>
22+
);
2823
}
2924

25+
Button.propTypes = propTypes;
26+
Button.defaultProps = defaultProps;
27+
3028
export default Button;

0 commit comments

Comments
 (0)