You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/guides/react-native.md
+140Lines changed: 140 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ class App extends React.Component {
24
24
exportdefaultApp;
25
25
```
26
26
27
+
<aname="native-controls"/>
27
28
## Native `<Control>`
28
29
29
30
The following React Native iOS form controls are available:
@@ -36,6 +37,8 @@ The following React Native iOS form controls are available:
36
37
-`<Control.Switch>`
37
38
-`<Control.TextInput>`
38
39
40
+
See [below](#examples) for examples.
41
+
39
42
The `model` prop is required for these controls to work with React Redux Form.
40
43
41
44
For most controls, the original `onFocus` and `onBlur` props are mapped to:
@@ -81,3 +84,140 @@ By default, the `<Errors>` component will render:
81
84
- and each error component as `<Text>`.
82
85
83
86
Of course, you can override this by specifying the component in the `wrapper={...}` and `component={...}` props of `<Errors />`.
87
+
88
+
<aname="examples"></a>
89
+
## Control.Picker with Picker.Items
90
+
Simply import `Picker` from `react-native`, and pass the `Picker.Item`s in as children.
91
+
92
+
```jsx
93
+
importReact, { Picker } from'react-native';
94
+
import { Form, Control } from'react-redux-form/native';
95
+
96
+
classFormextendsReact.Component {
97
+
render() {
98
+
return (
99
+
<Form model="user">
100
+
<Control.Picker model=".gender">
101
+
<Picker.Item label="Male" value="male"/>
102
+
<Picker.Item label="Female" value="female"/>
103
+
<Picker.Item label="Other" value="other"/>
104
+
</Control.Picker>
105
+
</Form>
106
+
);
107
+
}
108
+
}
109
+
110
+
exportdefaultForm;
111
+
```
112
+
113
+
## Using Custom Form Components
114
+
To use a third-party form control component select the appropriate `Control` type (e.g., `Control.TextInput`) and override the `component` prop with your custom component. The custom component must resolve to one of the supported React Native form control types. See the supported types [here](#native-controls).
115
+
116
+
```jsx
117
+
importReactfrom'react-native';
118
+
import { Form, Control } from'react-redux-form/native';
119
+
import { Input } from'native-base';
120
+
121
+
classFormextendsReact.Component {
122
+
render() {
123
+
return (
124
+
<Form model="user">
125
+
<Control.TextInput
126
+
placeholder="Last Name"
127
+
model=".last_name"
128
+
component={Input}
129
+
/>
130
+
</Form>
131
+
);
132
+
}
133
+
}
134
+
135
+
exportdefaultForm;
136
+
```
137
+
138
+
## Using Non-Supported Custom Form Components
139
+
If you are using a non-standard form control that does not implement one of the standard React Native iOS form controls ([listed here](#native-controls)), you will need to manually redefine `mapProps` for the control's event handlers.
140
+
141
+
Below is an example of a custom `Picker` component with `mapProps` redefined.
142
+
143
+
```jsx
144
+
importReactfrom'react-native';
145
+
import { Form, Control } from'react-redux-form/native';
0 commit comments