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

I can't press more than 1 time

Open leopavez opened this issue 5 years ago • 9 comments

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.

leopavez avatar Jan 30 '21 20:01 leopavez

I can't reproduce this. Can you please link a repo so I can test this issue.

venkateshgbabu avatar Feb 06 '21 00:02 venkateshgbabu

I have the same problem

Ozeias01Nunes avatar Feb 19 '21 12:02 Ozeias01Nunes

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

balagurubaran avatar Mar 02 '21 02:03 balagurubaran

I've also had the same problem and now it's solved by the solution @balagurubaran offered

lomirus avatar Mar 17 '21 03:03 lomirus

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 avatar May 04 '21 06:05 aim8526

@aim8526 Same 😢

UPD: Nope, the problem was in my code

on3dd avatar May 07 '21 10:05 on3dd

not worked when checkbox is in flatlist

developeromI89 avatar Jun 11 '21 09:06 developeromI89

This solution worked for me https://abodeofmystories.blogspot.com/2021/07/ReactNative-Checkbox-cant-be-pressed-more-than-1-time-Android.html

ritzblogs avatar Jul 19 '21 19:07 ritzblogs

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 }); } }

imhassanjaved avatar Jul 27 '22 15:07 imhassanjaved