Just finished this multi-select button, I think there is no radio, always feel a little uncomfortable, because in the project I also did not use the radio, so I did not study the source code, so I found a bit on GitHub, find a very good, simple, not fancy.
Search for this on GitHub
React-native-flexi-radio-button
After the download, you can use it directly.
1 import React, { Component } from ‘react‘;
2 import {
3 StyleSheet,
4 Text,
5 View
6 } from ‘react-native‘;
7
8 import {RadioGroup, RadioButton} from ‘react-native-flexi-radio-button‘
9
10 class App extends Component{
11
12 constructor(){
13 super()
14 this.state = {
15 text: ‘‘
16 }
17 this.onSelect = this.onSelect.bind(this)
18 }
19
20 onSelect(index, value){
21 this.setState({
22 text: `Selected index: ${index} , value: ${value}`
23 })
24 }
25
26 render(){
27 return(
28 <View style={styles.container}>
29 <RadioGroup
30 onSelect = {(index, value) => this.onSelect(index, value)}
31 >
32 <RadioButton value={‘item1‘} >
33 <Text>This is item #1</Text>
34 </RadioButton>
35
36 <RadioButton value={‘item2‘}>
37 <Text>This is item #2</Text>
38 </RadioButton>
39
40 <RadioButton value={‘item3‘}>
41 <Text>This is item #3</Text>
42 </RadioButton>
43
44 </RadioGroup>
45
46 <Text style={styles.text}>{this.state.text}</Text>
47 </View>
48 )
49 }
50 }
51
52 let styles = StyleSheet.create({
53 container: {
54 marginTop: 40,
55 padding: 20
56 },
57 text: {
58 padding: 10,
59 fontSize: 14,
60 },
61 })
62
63 module.exports = App
React native RadioButton (radio button)