react-native-radio-group-external-state
v1.2.3
Published
A react-native radio-group component that doesn't use internal state
Downloads
32
Maintainers
Readme
React Native Radio Group External State
A radio group component that doesn't use the internal state of itself!
Why another radio-group for React Native?
Because I've tried many of those components called react-native-radio-group and they didn't fit into my mind; so I created mine.
It uses your states!
Installation
npm install --save react-native-radio-group-external-state
or
yarn add react-native-radio-group-external-state
Usage
import React, { Component } from 'react'
import { View } from 'react-native'
import RadioGroup from 'react-native-radio-group-external-state'
export default class App extends Component {
state = { gender: 'unspecified' }
onChange_gender = value => {
this.setState({ gender: value })
}
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
}}
>
<RadioGroup
options={[
{ value: 'male', label: 'Male' },
{ value: 'female', label: 'Female' }
]}
value={this.state.gender}
onChange={this.onChange_gender}
groupStyle={{ marginTop: 10 }}
optionStyle={{ marginHorizontal: 14 }}
labelStyle={{ paddingHorizontal: 8 }}
buttonSize={26}
rtl
/>
</View>
)
}
}