Reputation: 29
I want to use two component Text and Radiobutton with map. Like this..
please help me!
{Object.keys(temp_data).map(room => (
<Text> {room} </Text>
<RadioForm
radio_props={radio_props}
initial={0}
buttonColor={'#2196f3'}
animation={true}
onPress={(value) => {this.setState({value:value})}}
/>
))
}
Upvotes: 0
Views: 46
Reputation: 3020
You can use fragment
{Object.keys(temp_data).map(room => (
<React.Fragment>
<Text> {room} </Text>
<RadioForm
radio_props={radio_props}
initial={0}
buttonColor={'#2196f3'}
animation={true}
onPress={(value) => {this.setState({value:value})}}
/>
</React.Fragment>
))
}
or
{Object.keys(temp_data).map(room => (
<>
<Text> {room} </Text>
<RadioForm
radio_props={radio_props}
initial={0}
buttonColor={'#2196f3'}
animation={true}
onPress={(value) => {this.setState({value:value})}}
/>
</>
))
}
I think this way more cleaner
Upvotes: 1
Reputation: 2452
Just wrap them in a View
{Object.keys(temp_data).map(room => (
<View>
<Text> {room} </Text>
<RadioForm
radio_props={radio_props}
initial={0}
buttonColor={'#2196f3'}
animation={true}
onPress={(value) => {this.setState({value:value})}}
/>
</View>
))
}
Upvotes: 0