Skip to content

Commit

Permalink
use state. Fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed May 24, 2016
1 parent 1f348eb commit df79931
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-checkbox",
"version": "1.3.5",
"version": "1.3.6",
"description": "checkbox ui component for react",
"keywords": [
"react",
Expand Down
12 changes: 6 additions & 6 deletions src/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ export default class Checkbox extends React.Component {
handleFocus = (e) => {
this.setState({ focus: true });
this.props.onFocus(e);
}
};

handleBlur = (e) => {
this.setState({ focus: false });
this.props.onBlur(e);
}
};

handleChange = (e) => {
const checked = e.target.checked;
const { checked } = this.state;
if (!('checked' in this.props)) {
this.setState({
checked: checked ? 1 : 0,
checked: !checked,
});
}
this.props.onChange({
target: {
...this.props,
checked,
checked: !checked,
},
stopPropagation() {
e.stopPropagation();
Expand All @@ -54,7 +54,7 @@ export default class Checkbox extends React.Component {
e.preventDefault();
},
});
}
};

render() {
const props = { ...this.props };
Expand Down

0 comments on commit df79931

Please sign in to comment.