If you want to add a Radio button in React Native, follow this:
First, Install
npm i react-native-simple-radio-button --save
Started with this code:
import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button'; constructor(props) { super(props); this.navigationModal = React.createRef(); this.state = ({ loading: false, radioButton:'value1', }) }
<ScrollView style={styles.mainWrapper}> <View style={styles.mainContainer}> <View style={styles.inputCheckbox}> <CheckBox title='Male' checkedIcon='dot-circle-o' uncheckedIcon='circle-o' checked={this.state.radioButton === 'Male'} onPress={() => this.setState({radioButton: 'Male'})} ></CheckBox> <CheckBox title='Female' checkedIcon='dot-circle-o' uncheckedIcon='circle-o' checked={this.state.radioButton === 'Female'} onPress={() => this.setState({radioButton: 'Female'})} ></CheckBox> <CheckBox title='Other' checkedIcon='dot-circle-o' uncheckedIcon='circle-o' checked={this.state.radioButton === 'Other'} onPress={() => this.setState({radioButton: 'Other'})} ></CheckBox> </View> </View> <CreateTables></CreateTables> </ScrollView>
const styles = StyleSheet.create({ mainContainer: { flex: 1, backgroundColor: '#F5F8FF', flexDirection: 'column', flexWrap: 'nowrap', paddingTop: 20 }, inputCheckbox: { marginLeft: 20, marginRight: 20 } });
Question and answer is powered by AnsPress.io