How to toggle boolean state of react component?

前端 未结 9 1905
别跟我提以往
别跟我提以往 2021-01-29 23:45

I\'d like to know how to toggle a boolean state of a react component. For instance:

I have boolean state check in the constructor of my component:

const         


        
9条回答
  •  梦谈多话
    2021-01-30 00:19

    Try:

    
    

    Using check: !check.value means it is looking for the check object, which you haven't declared.

    You need to specify that you want the opposite value of this.state.check.

提交回复
热议问题