Skip to content

Commit

Permalink
Adapt syntax after React upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
akikoo committed Jun 14, 2017
1 parent a1df69e commit 5b974ec
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions components/Button.jsx
Expand Up @@ -3,32 +3,35 @@
var React = require('react');
var PropTypes = require('prop-types');

var Button = React.createClass({
getDefaultProps() {
return {
type: 'button',
value: 'Send',
onClick: null
};
},
class Button extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}

handleClick(e) {
if (this.props.onClick) {
this.props.onClick(e);
}
},
}

render() {
return (
<button className="btn btn--primary" type="button" onClick={this.handleClick}>{this.props.value}</button>
);
}
});
};

Button.propTypes = {
type: PropTypes.string,
value: PropTypes.string.isRequired,
onClick: PropTypes.func
};

module.exports = Button;
Button.defaultProps = {
type: 'button',
value: 'Send',
onClick: null
};

module.exports = Button;

0 comments on commit 5b974ec

Please sign in to comment.