How to set default Checked in checkbox ReactJS?

前端 未结 16 1980
难免孤独
难免孤独 2020-11-27 11:51

I\'m having trouble to update the checkbox state after it\'s assigned with default value checked="checked" in React.

var rCheck = React         


        
16条回答
  •  囚心锁ツ
    2020-11-27 12:40

    You may pass "true" or "" to the checked property of input checkbox. The empty quotes ("") will be understood as false and the item will be unchecked.

    let checked = variable === value ? "true" : "";
    
    
    

提交回复
热议问题