0
Guys, how can I make this dynamic checkbox? Because this way it is there I have to create a useState for each checkbox, but when I go to pull these values from the bank will come diametrically, how to create the useState also dynamically? Snack of the working code: https://snack.expo.io/@wendellchristian/checkbox
import React, { useEffect, useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
import { RadioGroup, CheckBox  } from 'react-native-btr';
export default function App() {
    const [checked, setChecked] = useState(false);
    const [checked2, setChecked2] = useState(false);
    const [checked3, setChecked3] = useState(false);
  return (
    <View style={styles.container}>
      <View style={styles.viewCheckbox}>
        <View style={styles.checkbox}>
          <CheckBox
            checked={checked}
            onPress={item => setChecked(!checked)}
            color='#009688'
          />
        </View>
        <Text onPress={item => setChecked(!checked)}> Checkbox 1</Text>
      </View>
      <View style={styles.viewCheckbox}>
        <View style={styles.checkbox}>
          <CheckBox
            checked={checked2}
            onPress={item => setChecked2(!checked2)}
            color='#009688'
          />
        </View>
        <Text onPress={item => setChecked2(!checked2)}> Checkbox 2</Text>
      </View>
      
      <View style={styles.viewCheckbox}>
        <View style={styles.checkbox}>
          <CheckBox
            checked={checked3}
            onPress={item => setChecked3(!checked3)}
            color='#009688'
          />
        </View>
        <Text onPress={item => setChecked3(!checked3)}> Checkbox 3</Text>
      </View>
    </View>
  );
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
  viewCheckbox: {
    flexDirection: "row",
    marginBottom: 10,
  },
  checkbox: {
    width: 24,
  }
});
						
Create a simple array where objects represent checked and id to know who they are
– novic