I can't press more than 1 time
friends, I have problems using the checkbox. I can only press it 1 time. When clicking on the checkbox (checked with a console.log) it only changes its value and returns the console log the first time it is pressed, since after that, the amounts that you press do absolutely nothing and do not change value.
This is my useState Hooks:
const [toggleCheckBox, setToggleCheckBox] = useState(false)
This is my CheckBox code:
<CheckBox
disabled={false}
value={toggleCheckBox}
onValueChange={(newValue) => setToggleCheckBox(newValue)}/>
I tried all the ways I found on the internet and with all of them it's the same.
I can't reproduce this. Can you please link a repo so I can test this issue.
I have the same problem
Am also facing the same problem in my android project. In iOS is working as expected.
The below piece of code, Am using to render the Check box.
<CheckBox
style = {{marginLeft:0 , height:20}}
onFillColor = { Color_Constant.color.app_yellow }
onCheckColor = 'white'
onTintColor = { Color_Constant.color.app_yellow }
tintColor = { Color_Constant.color.app_yellow }
tintColors={{ true: Color_Constant.color.app_yellow, false: Color_Constant.color.app_yellow }}
disabled={false}
value={this.state.CheckBoxStatus}
onValueChange={(value) => {
}}
/>
Found the solution https://www.youtube.com/watch?time_continue=9&v=N1I67FaluFE&feature=emb_logo
I've also had the same problem and now it's solved by the solution @balagurubaran offered
Is this issue solved?
I am facing the same issue, tried, both onChange() and onValueChange() events, both are work once in a single render. if I re-render then it works one more time.
Thanks in advance for any suggestions.
@aim8526 Same 😢
UPD: Nope, the problem was in my code
not worked when checkbox is in flatlist
This solution worked for me https://abodeofmystories.blogspot.com/2021/07/ReactNative-Checkbox-cant-be-pressed-more-than-1-time-Android.html
I had same issue, I did this to solve it. You just need to change any used/unused state variable in the onValueChange listener.
onValueChange={(newValue) => { setValue(newValue); this.setState({ check: !check }); } }