I'm working to make my React-Native more dynamic and am building components by mapping an array. Im stuck trying to dynamically assign the prop values because they are already within a bracket.
Is there a way to accomplish this example below? Can I escape the parameter somehow or double bracket the value I need?
// Sample array
fieldArray = [
{"DefaultValue": "ABCDEF",
"Name": "Field1"},
{"DefaultValue": "123456",
"Name": "Field2"}
]
// Old way having static defined components
<TextInput
value={this.state.Field1}
onChangeText={() => {}}
/>
<TextInput
value={this.state.Field2}
onChangeText={() => {}}
/>
What I'd like to do is:
{fieldArray.map((x) =>
<TextInput
value={this.state.{x.Name}} // <-- This is where I am stuck, can I double bracket in a .map()??
onChangeText={() => {}}
/>
)}