0
<input {...{type: 'checkbox', name, checked, readOnly: true, disabled: true}} />

Can someone tell me why my checkbox is not being disabled?

Any help is appreciated!

Skoby
  • 161
  • 1
  • 2
  • 10
  • it might make sense to check what devtools say – Daniel Khoroshko Nov 16 '18 at 12:42
  • i don't see any error or warning on devtools – Skoby Nov 16 '18 at 12:45
  • Use React.createElement('input',{type: 'checkbox', defaultChecked: false}); thats works fine. Also https://stackoverflow.com/questions/32174317/how-to-set-default-checked-in-checkbox-reactjs – episch Nov 16 '18 at 12:48
  • 1
    [It should work fine](https://codesandbox.io/s/23xv3m73r0). Can you create a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve)? – Tholle Nov 16 '18 at 12:48

1 Answers1

0

Found the issue: the onClick handler was one level above the input tag (parent div). If you do it like this it should work as expected:

<input {...{type: 'checkbox', name, checked, onClick: this.onChange, disabled: false}} />
Skoby
  • 161
  • 1
  • 2
  • 10