Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

react native : Unable to uncheck checkbox

$
0
0

In my example I present a checkboxes list butI cant uncheck the checkboxes.Now I can only check them but cant uncheck .How should I fix MY code that it will works fine ? ?

 const [checkList, setCheckList] = useState<any[]>(actionList.map(e => ({ key: e.key, checked: false })));  const isChecked = (key) => {    checkList.filter(e => e.key == key)[0].checked  }  const renderActionItem = ({ item, index }) => {    return (<TouchableOpacity        key={index}        activeOpacity={.7}        style={styles.touchableOpacity}        onPress={() => { console.log(item) }}><CheckBox          style={styles.checkBox}          tintColors={{ true: 'white', false: 'white' }}          value={isChecked(item.key)}          onValueChange={() => {            const newCheckList = checkList.slice()            newCheckList.forEach(e => {              if (e.key == item.key) {                e.checked = !e.checked              }            })            setCheckList(newCheckList)          }}        /><Text style={styles.labelText}>{`${item.sequenceID} . ${item.label}`}</Text></TouchableOpacity>    )  }

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>