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: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
# React Redux Form
2
2
3
3
[](https://gitter.im/react-redux-form/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
It can also be a function that returns a string model. See [the documentation on tracking](../guides/tracking.md) for more information.
93
92
94
-
<h2id="prop-mapProps"></h2>
95
-
## `mapProps={{...}}`
93
+
## `mapProps={{...}}` {#prop-mapProps}
96
94
_(Object | Function)_: A custom mapping from props provided by `Control` to props received by the component. Can be:
97
95
98
96
- An object, where each value is a function from original props to corresponding value in result props.
@@ -114,8 +112,7 @@ Examples:
114
112
115
113
See [the documentation on custom controls](../guides/custom-controls.md) for more information.
116
114
117
-
<h2id="prop-updateOn"></h2>
118
-
## `updateOn="..."`
115
+
## `updateOn="..."` {#prop-updateOn}
119
116
_(String | Array)_: A string/array of strings specifying when the component should dispatch a `change(...)` action, with one of these values:
120
117
121
118
-`"change"` - will dispatch in `onChange`
@@ -129,8 +126,7 @@ You can also specify `updateOn={['change', 'blur']}` as an array of one or more
129
126
### Notes
130
127
- Use the `changeAction` prop if you want to dispatch custom actions along with the `actions.change(...)` action.
131
128
132
-
<h2id="prop-validators"></h2>
133
-
## `validators={{...}}`
129
+
## `validators={{...}}` {#prop-validators}
134
130
_(Object)_: A map where the keys are validation keys, and the values are the corresponding functions that determine the validity of each key, given the model's value.
135
131
136
132
For example, this control validates that a username exists and is longer than 4 characters:
_(String | Array)_: A string/array of strings specifying when validation should occur. By default, validation happens with whatever `updateOn` is set to. The `validateOn` property can have these values:
164
159
-`"change"` - validate on the `onChange` event handler
165
160
-`"blur"` - validate on the `onBlur` event handler
@@ -169,8 +164,7 @@ _(String | Array)_: A string/array of strings specifying when validation should
169
164
- Validation will always occur **on load**; i.e., when the component is mounted. This is to ensure an accurate validation state for a new form.
170
165
- To avoid displaying error messages on load (as controls might be invalid), use the `.pristine` property of the control when conditionally showing error messages, or use the `<Errors>` component.
_(Object)_: A map where the keys are validation keys, and the values are the corresponding functions that (asynchronously) determine the validity of each key, given the model's value.
175
169
176
170
Each async validator function is called with 2 arguments:
@@ -195,15 +189,13 @@ import isAvailable from '../path/to/is-available';
195
189
### Notes
196
190
- Async validators will run on `blur`, unless you specify otherwise in the `asyncValidateOn="..."` prop.
_(String | Array)_: A string/array of strings specifying when async validation should occur. By default, validation happens on `"blur"`. The `asyncValidateOn` property can have these values:
201
194
-`"change"` - validate on the `onChange` event handler
202
195
-`"blur"` (default) - validate on the `onBlur` event handler
203
196
-`"focus"` - validate on the `onFocus` event handler
204
197
205
-
<h2id="prop-errors"></h2>
206
-
## `errors={{...}}`
198
+
## `errors={{...}}` {#prop-errors}
207
199
_(Object)_: A map where the keys are error keys, and the values are the corresponding error validator functions that determine the invalidity of each key, given the model's value.
208
200
209
201
An **error validator** is a function that returns `true` or a truthy value (such as a string) if invalid, and `false` if valid.
@@ -220,8 +212,7 @@ For example, this control validates that a username exists and is longer than 4
220
212
/>
221
213
```
222
214
223
-
<h2id="prop-parser"></h2>
224
-
### `parser={() => ...}`
215
+
### `parser={() => ...}` {#prop-parser}
225
216
_(Function)_: A function that _parses_ the view value of the control before it is changed. It takes in two arguments:
226
217
-`value` - the view value that represents the _next_ model value
227
218
-`previous` (optional) - the current model value _before_ it is changed
An action creator (function) that specifies which action the `<Control>` component should use when dispatching a change to the model. For example, this action is similar to:
245
235
246
236
-`actions.change(model, value)` for text input controls
@@ -281,8 +271,7 @@ function changeAndSubmit(model, value) {
281
271
- Use `changeAction` to do any other custom actions whenever your value is to change.
282
272
- Since `changeAction` expects an action creator and `redux-thunk` is used, you can asynchronously dispatch actions (like the example above).
283
273
284
-
<h2id="prop-controlProps"></h2>
285
-
## `controlProps={{...}}`
274
+
## `controlProps={{...}}` {#prop-controlProps}
286
275
_(Object)_: A mapping of control-specific props that will be applied directly to the rendered control. In some cases, this can be a safer way of applying props, especially if there are naming conflicts between `<Control>`-specific props (such as `"model"`) and props that need to go on the rendered control (e.g., `<input {...props} />`).
287
276
288
277
The normal behavior is that any extraneous props on `<Control>` that are not part of `Control.propTypes` (which are documented here) will be given to the rendered input.
@@ -298,8 +287,7 @@ Example:
298
287
/>
299
288
```
300
289
301
-
<h2id="prop-component"></h2>
302
-
## `component={...}`
290
+
## `component={...}` {#prop-component}
303
291
_(Function | String | Node)_: A custom component can be passed into the `component={...}` prop, and standard control props and event handlers (such as `onChange`, `onBlur`, `onFocus`, `value`, etc.) will be mapped as expected:
0 commit comments