An easily customizable solution to make typed forms in react-native!
npm install react-native-typed-formsnpm install --save react-native-typed-forms
yarn add react-native-typed-forms
import { Form } from 'react-native-typed-form
#### Properties
| Property | Required | default | type |
| :------------- | :------- | :------ | :--------------- |
| model | yes | - | Object |
| value | no | null | Object - null\* |
| onFinish | yes | - | Function(Object) |
| disableAnswers | no | false | Boolean\\ |
On finish will provide a data value that can be provided AS IS to the value prop of the form, and the form itself will handle the data to preload the components.
\*If you do not provide a value (that is, the value produced by the onFinish method after completing a form) it will always create a new blank form. Providing a value preloads with data from previous iterations.
\\Extremely recommended to set as true always, this was an old mechanic that needs to be changed
#### Model
The model is the spec the lib will use to build the form, see the example for a more convoluted use, but basically it's the following:
`
{
type: formTypes.form, // always
answer: answerTypes.single, // answer types, multiple not docummented
fields: {
0: { // for now, indexes are required
type: formTypes.string, // any of the form component types
key: 'text_identifier', // key is required, has to be unique inside the form
content: {
text: 'This is a text field you can fill',
},
options: {
placeHolder: 'Filler text',
multiline: true,
default: '',
},
},
},
}
`
Each component has it's own unique content/options spec, which are due for documentation.
Example app
To run the example app
`
- git clone this repo
- cd example
- npm install
- react-native run-android
``