A simple react-native component to wrap your form fields and get their values without attaching listeners everywhere.
npm install --save react-native-form
Just put how many react-native components (fields) you want inside <Form>
with the prop name
defined. For example:
import Form from 'react-native-form'
<Form ref="form">
<TextInput name="input" />
<Switch name="switch" />
<SliderIOS name="slider" />
<PickerIOS name="picker" />
<DatePickerIOS name="datePicker" />
</Form>
and then you can get all values by calling this.refs.form.getValues()
.
Just pass a customFields
prop. Check out this example using the react-native-radio-buttons field:
var customFields = {
'RadioButtons': {
controlled: true,
valueProp: 'selectedOption',
callbackProp: 'onSelection',
}
}
<Form ref="form" customFields={customFields}>
<RadioButtons name="radioButtons" />
</Form>
react-native-form is licensed under the MIT license.