I'm allowing the user to select a number from picker it can by any no like 1,4,6 random. When he selects a number like 3 then 3 TextInputs will be shown and he will enter something in 3 input fields and I want to save these values into an array. How can do this in react native
I think I'm using a bad approach and I want someone expert who can make my code efficient and tell me how can I store values into an array.Regards
{this.state.noOfStores === 1 && (
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
)}
{this.state.noOfStores === 2 && (
<View>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
</View>
)}
{this.state.noOfStores === 3 && (
<View>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
</View>
)}
{this.state.noOfStores === 4 && (
<View>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
<TextInput
style={[
styles.input,
{
backgroundColor: theme.colors.lightGray,
},
]}
placeholder=" Name "
keyboardType={'default'}
placeholderTextColor="gray"
/>
</View>
)}