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

How is React Native multiple data input?

$
0
0

My English is not very good, sorry for that. There is a structure that I want to make multiple data entries. I will add separate json lines for each input. But I can add once from the same line. But I want to create a separate json data for each input. I am sharing the sample code. It doesn't work that way because it constantly updates the previous data in.

var families = [];for(let i = 0; i < formStep + 1; i++) {    families.push(<View key={i}><View><Text style={{ marginBottom: 5 }}>T.C</Text><Input                    placeholder='Lütfen T.C belirtin'                    style={{ marginBottom: 10 }}                                                onChangeText={(input) => this.setState(prevState => ({                                                  formData: [...prevState.formData, {tc: input}]                    }))}                /></View><View><Text style={{ marginBottom: 5 }}>İsim</Text><Input                    placeholder='Lütfen ad ve soyad belirtin'                    style={{ marginBottom: 10 }}                /></View><View><Text style={{ marginBottom: 5 }}>Meslek</Text><Input                    placeholder='Lütfen meslek belirtin'                    style={{ marginBottom: 10 }}                /></View>            {(formStep > 0) ? <Divider style={{marginBottom: 15, marginTop: 10}}></Divider> : null}</View>    )}

working input onChangeText method;

Array [  Object {"tc": "0",  },]Array [  Object {"tc": "0",  },  Object {"tc": "00",  },]Array [  Object {"tc": "0",  },  Object {"tc": "00",  },  Object {"tc": "000",  },]

But I want;

Array [  Object {"tc": "000",  },]

And then if there is more than one input;

Array [  Object {"tc": "000",  },  Object {"tc": "111",  },  Object {"tc": "222",  },]

I hope I could tell. Thanks for your help in advance.


Viewing all articles
Browse latest Browse all 6213

Trending Articles



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