Ad
How To Map The Radio Button And Retrieve The Value Without Duplicates
I use the library react-native-flexi-radio-button, and get problems when using map ()
I have tried to fill the value of the map item ()
_mapDuration() {
if (this.props.childList) {
return this.props.childList.map((item, i) => <RadioGroup
size={24}
thickness={1}
color="#FF9F4D"
highlightColor="#fff5ed"
selectedIndex={null}
onSelect={(index, value) =>
this.onSelectService(index, value)
}
style={{ marginTop: 10 }}
>
<RadioButton
value={item.duration}
color="#FF9F4D"
style={{ alignItems: 'center' }}
>
<View style={styles.line}>
<View
style={{
flexDirection: 'row',
}}
>
<Text style={styles.textChoice}>{item.duration} Menit</Text>
<Text style={styles.textSubCOD}>
{/* ( 1 jam ) */}
</Text>
<Text style={styles.textUang}> Rp {item.price} </Text>
</View>
</View>
</RadioButton>
</RadioGroup>
)
}
}
I want to get value and the radio functions without duplicate radio buttons
Ad
Answer
Use the key value to resolve it. And add parentheses.
_mapDuration() {
if (this.props.childList) {
return this.props.childList.map((item, i) => (<RadioGroup
size={24}
thickness={1}
color="#FF9F4D"
highlightColor="#fff5ed"
selectedIndex={null}
onSelect={(index, value) =>
this.onSelectService(index, value)
}
style={{ marginTop: 10 }}
>
<RadioButton
key={i}
value={item.duration}
color="#FF9F4D"
style={{ alignItems: 'center' }}
>
<View style={styles.line}>
<View
style={{
flexDirection: 'row',
}}
>
<Text style={styles.textChoice}>{item.duration} Menit</Text>
<Text style={styles.textSubCOD}>
{/* ( 1 jam ) */}
</Text>
<Text style={styles.textUang}> Rp {item.price} </Text>
</View>
</View>
</RadioButton>
</RadioGroup>)
)
}
}
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad