From 7833860798c4b6a6eb8499955bd4627457b39900 Mon Sep 17 00:00:00 2001 From: "Bool.Yang" Date: Tue, 24 Oct 2017 11:03:40 -0500 Subject: [PATCH] Update index.js remove `onClick`, `isChecked` and `isIndeterminate` required , because they have default value . pass `this` object to `onClick` callback function, make it's easy to get this component when need. `onClick` will be called only when it has value. --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d7a84a3..46ee653 100755 --- a/index.js +++ b/index.js @@ -36,9 +36,9 @@ export default class CheckBox extends Component { rightTextStyle: PropTypes.object, checkedImage: PropTypes.element, unCheckedImage: PropTypes.element, - onClick: PropTypes.func.isRequired, - isChecked: PropTypes.bool.isRequired, - isIndeterminate: PropTypes.bool.isRequired, + onClick: PropTypes.func, + isChecked: PropTypes.bool, + isIndeterminate: PropTypes.bool, checkBoxColor: PropTypes.string, disabled: PropTypes.bool, } @@ -52,7 +52,7 @@ export default class CheckBox extends Component { this.setState({ isChecked: !this.state.isChecked }) - this.props.onClick(); + this.props.onClick && this.props.onClick(this); } _renderLeft() { if (this.props.leftTextView)return this.props.leftTextView;