I want to be able to add multiple checkboxes in my expo react native app. I'm providing the relevant code below. I have an array in my class which holds the details about the checkbox, it has an id, the text which has to go alongside and a check for whether the checkbox is checked or not.
My Code
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0,
inputTxt: "",
checks: [
{id: 1, txt: "first check", isChecked: false },
{id: 2, txt: "second check", isChecked: false }
]
};
}
render() {
return (
<View style={styles.container}>
<Text style={styles.text}>Details Screen</Text>
<View>
<View style={styles.checkboxContainer}>
<CheckBox/>
{/* Add all the checkboxes from my this.state.checks array here */}
<Text style={styles.label}>Do you like React Native?</Text>
</View>
</View>
[...]
</View>
);
}
}
Aucun commentaire:
Enregistrer un commentaire