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

Commit 7c49bad

Browse files
authored
Merge pull request #861 from mfal/fix/control-typings
Add debounce prop of Control component to typings and API docs
2 parents 68c0f9a + c9e4103 commit 7c49bad

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

docs/api/Control.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [`model` (required)](#prop-model)
66
- [`mapProps`](#prop-mapProps)
77
- [`updateOn`](#prop-updateOn)
8+
- [`debounce`](#prop-debounce)
89
- [`validators`](#prop-validators)
910
- [`validateOn`](#prop-validateOn)
1011
- [`asyncValidators`](#prop-asyncValidators)
@@ -154,6 +155,9 @@ const length = (val) => val.length > 8;
154155
/>
155156
```
156157

158+
## `debounce={...}` {#prop-debounce}
159+
_(Number)_: The time in milliseconds, by which the change action will be debounced.
160+
157161
## `validateOn="..."` {#prop-validateOn}
158162
_(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:
159163
- `"change"` - validate on the `onChange` event handler

react-redux-form.d.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,19 @@ export interface ControlProps<T> extends React.HTMLProps<T> {
123123
*/
124124
model: string | ModelGetterFn;
125125
/**
126-
* If updateOn is a function, the function given will be called with the change action creator.
127-
* The function given will be called in onChange.
126+
* A string/array of strings specifying when the component should dispatch a change(...) action, with one of these values:
128127
*
129-
* If a string, updateOn can be one of these values:
130-
* * change - will dispatch in onChange
131-
* * blur - will dispatch in onBlur
132-
* * focus - will dispatch in onFocus
133-
* @example
134-
* import debounce from 'lodash/debounce';
135-
* <Field model="test.bounce" updateOn={(change) => debounce(change, 1000)}>
136-
* <input type="text" />
137-
* </Field>
128+
* change - will dispatch in onChange
129+
* blur - will dispatch in onBlur
130+
* focus - will dispatch in onFocus
131+
*
132+
* @default change
138133
*/
139134
updateOn?: UpdateOn | UpdateOn[];
135+
/**
136+
* The time in milliseconds, by which the change action will be debounced.
137+
*/
138+
debounce?: number;
140139
/**
141140
* 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.
142141
* Validator functions accept the value and return true if the field is valid.

0 commit comments

Comments
 (0)