Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julianocomg/react-native-form
A simple react-native component to wrap your form fields and get their values with just one single method.
https://github.com/julianocomg/react-native-form
android form ios react-native
Last synced: about 1 month ago
JSON representation
A simple react-native component to wrap your form fields and get their values with just one single method.
- Host: GitHub
- URL: https://github.com/julianocomg/react-native-form
- Owner: julianocomg
- License: mit
- Created: 2015-10-15T15:24:21.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-26T15:39:46.000Z (over 6 years ago)
- Last Synced: 2024-12-02T01:12:12.810Z (about 1 month ago)
- Topics: android, form, ios, react-native
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/react-native-form
- Size: 27.3 KB
- Stars: 146
- Watchers: 6
- Forks: 17
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-form ★138 - A simple react-native component to wrap your form fields! (Components / Forms)
- awesome-react-native - react-native-form ★138 - A simple react-native component to wrap your form fields! (Components / Forms)
- awesome-react-native - react-native-form - A simple react-native component to wrap your form fields! ![](https://img.shields.io/github/stars/julianocomg/react-native-form.svg?style=social&label=Star) (Components / Forms)
- awesome-react-native - react-native-form ★138 - A simple react-native component to wrap your form fields! (Components / Forms)
- awesome-react-native-ui - react-native-form ★100 - A simple react-native component to wrap your form fields! (Components / Forms)
- awesome-react-native - react-native-form ★138 - A simple react-native component to wrap your form fields! (Components / Forms)
README
# react-native-form
A simple react-native component to wrap your form fields and get their values without attaching listeners everywhere.## Installation
```
npm install --save react-native-form
```## Usage
Just put your fields inside the form, with 2 props:***`name`*** => Your key to retrieve the value (required)
***`type`*** => The field type (required)
***`key`*** => Required for fields with the same name
```javascript
import Form from 'react-native-form'
// Yes, it doesn't matter how deep they are :)
// Yes, we support form serialization, like the web```
And then you can call ***`this.refs.form.getValues()`***.
You will get an object with all the values serialized. Simple as that.## Do you want to use custom fields?
Just pass the prop ***`customFields`*** to the form. Check out the example below using the [react-native-radio-buttons](https://github.com/ArnaudRinquin/react-native-radio-buttons) field:
```javascript
var customFields = {
'RadioButtons': {
controlled: true,
valueProp: 'selectedOption',
callbackProp: 'onSelection',
}
}
```
## Support for Accordion
If you have form fields under an Accordion component, add:
```javascript
type="Accordion"
```to the Accordion component to have Form include the Accordion children.
## License
react-native-form is licensed under the [MIT license](LICENSE).