react-native-checkbox-heaven icon indicating copy to clipboard operation
react-native-checkbox-heaven copied to clipboard

Cannot prevent checkbox from being checked

Open daltondanis opened this issue 7 years ago • 3 comments

There is no disabled or prevent interaction with the checkbox and onChange you can't return false to prevent the box from being checked

Still checked={this.state} has no effect when doing setState

was it suppose to be fixed with commit#3731f5e?

daltondanis avatar Jul 17 '17 22:07 daltondanis

@bcitdaltond Are you still having this problem? If so, is there a reason you can't simply set checked={false} in the properties?

danascheider avatar Jun 06 '18 17:06 danascheider

I'm having something similar. If I set disabled to true I would expect that the state of the checkbox doesn't change. or with an empty function maybe ?.

<CheckBox disabled={true} checked={this.state.checkbox} onChange={() => {}} label="test" />

albertpb avatar Jun 28 '18 03:06 albertpb

I fixed it, in the method _onChange added a check for disabled prop:

_onChange() { if(!this.props.disabled) { const newVal = !this.state.checked const { onChange } = this.props this.setState({ checked:newVal }, () => { onChange(newVal) }) } }

albertpb avatar Jun 28 '18 03:06 albertpb