Help me on this ? This problem is easily solve if I hardcode each unique button to useState But I need to loop to create checkbox buttons since the button is no static "originalBranch" always change. When I'm using code below it always shows Too many re-render I'm out of idea on how to change / set the value of each unique loop.
const createButton = () =>{
const views = []
let col
let setcol
for(let i = 0 ; i < originalBranch.length ; i ++){
col="boolean"+originalBranch[i].Office_Code
setcol='set'+originalBranch[i].Office_Code
const [col,setcol]=useState(true)
views.push(
<View style={styles.buttonFilter3}>
<CheckBox
value={col}
onChange={
setcol(!col)
}
/>
<Text>{originalBranch[i].Office_Code}</Text>
</View>
)
}
return views
}
Aucun commentaire:
Enregistrer un commentaire