Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 1023edd

Browse files
committed
Merge branch 'master' of github.com:davidkpiano/react-redux-form
2 parents 405d42c + 5542eb2 commit 1023edd

File tree

6 files changed

+62
-108
lines changed

6 files changed

+62
-108
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# React Redux Form
22

33
[![Join the chat at https://gitter.im/react-redux-form/Lobby](https://badges.gitter.im/react-redux-form/Lobby.svg)](https://gitter.im/react-redux-form/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
[![Build Status](https://travis-ci.org/davidkpiano/react-redux-form.svg?branch=master)](https://travis-ci.org/davidkpiano/react-redux-form) [![npm version](https://badge.fury.io/js/react-redux-form.svg)](https://badge.fury.io/js/react-redux-form)
4+
[![Build Status](https://travis-ci.org/davidkpiano/react-redux-form.svg?branch=master)](https://travis-ci.org/davidkpiano/react-redux-form)
5+
[![npm version](https://badge.fury.io/js/react-redux-form.svg)](https://badge.fury.io/js/react-redux-form)
6+
[![CDNJS](https://img.shields.io/cdnjs/v/react-redux-form.svg)](https://cdnjs.com/libraries/react-redux-form)
57

68
## [Read the Documentation](https://davidkpiano.github.io/react-redux-form/docs.html)
79

docs/api/Control.md

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [`controlProps`](#prop-controlProps)
1616
- [`component`](#prop-component)
1717
- [`ignore`](#prop-ignore)
18-
- [`disabled`](#disabled)
18+
- [`disabled`](#prop-disabled)
1919
- [`getRef`](#prop-getRef)
2020
- [`persist`](#prop-persist)
2121
- [`getValue`](#prop-getValue)
@@ -74,8 +74,7 @@ export default App; // no need to connect
7474

7575
# Prop Types
7676

77-
<h2 id="prop-model"></h2>
78-
## `model="..."` (required)
77+
## `model="..."` (required) {#prop-model}
7978

8079
_(String | Function)_: The string representing the model value in the store.
8180
```jsx
@@ -91,8 +90,7 @@ export default createStore(combineForms({
9190

9291
It can also be a function that returns a string model. See [the documentation on tracking](../guides/tracking.md) for more information.
9392

94-
<h2 id="prop-mapProps"></h2>
95-
## `mapProps={{...}}`
93+
## `mapProps={{...}}` {#prop-mapProps}
9694
_(Object | Function)_: A custom mapping from props provided by `Control` to props received by the component. Can be:
9795

9896
- An object, where each value is a function from original props to corresponding value in result props.
@@ -114,8 +112,7 @@ Examples:
114112

115113
See [the documentation on custom controls](../guides/custom-controls.md) for more information.
116114

117-
<h2 id="prop-updateOn"></h2>
118-
## `updateOn="..."`
115+
## `updateOn="..."` {#prop-updateOn}
119116
_(String | Array)_: A string/array of strings specifying when the component should dispatch a `change(...)` action, with one of these values:
120117

121118
- `"change"` - will dispatch in `onChange`
@@ -129,8 +126,7 @@ You can also specify `updateOn={['change', 'blur']}` as an array of one or more
129126
### Notes
130127
- Use the `changeAction` prop if you want to dispatch custom actions along with the `actions.change(...)` action.
131128

132-
<h2 id="prop-validators"></h2>
133-
## `validators={{...}}`
129+
## `validators={{...}}` {#prop-validators}
134130
_(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.
135131

136132
For example, this control validates that a username exists and is longer than 4 characters:
@@ -158,8 +154,7 @@ const length = (val) => val.length > 8;
158154
/>
159155
```
160156

161-
<h2 id="prop-validateOn"></h2>
162-
## `validateOn="..."`
157+
## `validateOn="..."` {#prop-validateOn}
163158
_(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:
164159
- `"change"` - validate on the `onChange` event handler
165160
- `"blur"` - validate on the `onBlur` event handler
@@ -169,8 +164,7 @@ _(String | Array)_: A string/array of strings specifying when validation should
169164
- 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.
170165
- 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.
171166

172-
<h2 id="prop-asyncValidators"></h2>
173-
## `asyncValidators={{...}}`
167+
## `asyncValidators={{...}}` {#prop-asyncValidators}
174168
_(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.
175169

176170
Each async validator function is called with 2 arguments:
@@ -195,15 +189,13 @@ import isAvailable from '../path/to/is-available';
195189
### Notes
196190
- Async validators will run on `blur`, unless you specify otherwise in the `asyncValidateOn="..."` prop.
197191

198-
<h2 id="prop-asyncValidateOn"></h2>
199-
## `asyncValidateOn="..."`
192+
## `asyncValidateOn="..."` {#prop-asyncValidateOn}
200193
_(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:
201194
- `"change"` - validate on the `onChange` event handler
202195
- `"blur"` (default) - validate on the `onBlur` event handler
203196
- `"focus"` - validate on the `onFocus` event handler
204197

205-
<h2 id="prop-errors"></h2>
206-
## `errors={{...}}`
198+
## `errors={{...}}` {#prop-errors}
207199
_(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.
208200

209201
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
220212
/>
221213
```
222214

223-
<h2 id="prop-parser"></h2>
224-
### `parser={() => ...}`
215+
### `parser={() => ...}` {#prop-parser}
225216
_(Function)_: A function that _parses_ the view value of the control before it is changed. It takes in two arguments:
226217
- `value` - the view value that represents the _next_ model value
227218
- `previous` (optional) - the current model value _before_ it is changed
@@ -239,8 +230,7 @@ function toAge(value) {
239230
>
240231
```
241232

242-
<h2 id="prop-changeAction"></h2>
243-
## `changeAction={() => ...}`
233+
## `changeAction={() => ...}` {#prop-changeAction}
244234
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:
245235

246236
- `actions.change(model, value)` for text input controls
@@ -281,8 +271,7 @@ function changeAndSubmit(model, value) {
281271
- Use `changeAction` to do any other custom actions whenever your value is to change.
282272
- Since `changeAction` expects an action creator and `redux-thunk` is used, you can asynchronously dispatch actions (like the example above).
283273

284-
<h2 id="prop-controlProps"></h2>
285-
## `controlProps={{...}}`
274+
## `controlProps={{...}}` {#prop-controlProps}
286275
_(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} />`).
287276

288277
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:
298287
/>
299288
```
300289

301-
<h2 id="prop-component"></h2>
302-
## `component={...}`
290+
## `component={...}` {#prop-component}
303291
_(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:
304292

305293
```jsx
@@ -314,8 +302,7 @@ const MyTextInput = (props) => <input className="my-input" {...props} />;
314302
/>
315303
```
316304

317-
<h2 id="prop-ignore"></h2>
318-
## `ignore={[...]}`
305+
## `ignore={[...]}` {#prop-ignore}
319306
_(String | Array)_: The event(s) that you want the `<Control>` to ignore. This can be good for performance and/or for de-cluttering the console log.
320307

321308
For instance, if you don't care whether a `<Control>` is focused or blurred:
@@ -328,7 +315,7 @@ For instance, if you don't care whether a `<Control>` is focused or blurred:
328315
/>
329316
```
330317

331-
## `disabled={...}`
318+
## `disabled={...}` {#prop-disabled}
332319
_(Any)_: The `disabled` prop works just like you'd expect for controls that support the HTML5 `disabled` attribute.
333320

334321
However, in `<Control>`, it can be a boolean, or a function, string, or object as a [Lodash iteratee](https://lodash.com/docs#iteratee).
@@ -351,8 +338,7 @@ For example:
351338

352339
(since: version 1.3.0)
353340

354-
<h2 id="prop-getRef"></h2>
355-
## `getRef={() => ...}`
341+
## `getRef={() => ...}` {#prop-getRef}
356342
_(Function)_: Calls the callback provided to the `getRef` prop with the node instance. Similar to `ref`.
357343

358344
```jsx
@@ -362,8 +348,7 @@ _(Function)_: Calls the callback provided to the `getRef` prop with the node ins
362348
/>
363349
```
364350

365-
<h2 id="prop-persist"></h2>
366-
## `persist={false}`
351+
## `persist={false}` {#prop-persist}
367352
_(Boolean)_: Signifies that the field state (validation, etc.) should not persist when the component is unmounted. Default: `false`
368353

369354
```jsx
@@ -377,7 +362,7 @@ _(Boolean)_: Signifies that the field state (validation, etc.) should not persis
377362
/>
378363
```
379364

380-
## `getValue={(event, props) => ...}`
365+
## `getValue={(event, props) => ...}` {#prop-getValue}
381366
_(Function)_: Determines the value given the `event` (from `onChange`) and optionally the control component's `props`.
382367

383368
By default, the `getValue` function returns the value by hecking if the `event` is a DOM event.
@@ -395,7 +380,7 @@ For `<Control.checkbox />`, the default `getValue` function is:
395380
/>
396381
```
397382

398-
## `isToggle={false}`
383+
## `isToggle={false}` {#prop-isToggle}
399384
_(Boolean)_: Signifies that the control is a toggle (e.g., a checkbox or a radio). If `true`, then some optimizations are made.
400385

401386
Default: `true` for `<Control.radio>` and `<Control.checkbox>`, `false` for all other controls.

0 commit comments

Comments
 (0)