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

Commit 8c7ec89

Browse files
committed
Document the subtle difference between load and change.silent. Fixes #703
1 parent 4c4e6a4 commit 8c7ec89

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/api/actions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,16 @@ dispatch(actions.move('foo.bar', 2, 0));
241241
## `actions.load(model, value)`
242242
Dispatches an `actions.change(...)` action that loads (updates) the `model` with `value` silently. It does not trigger any effects of a `CHANGE` action in the form reducer.
243243

244+
It also sets the `.loadedValue` of the model's `field` to the dispatched `value`.
245+
244246
### Arguments
245247
- `model` _(String | Function)_: the model whose value will be changed
246248
- `value` _(any)_: the value to load (update) the model with
247249

248250
### Notes
249251
- This action is useful when you need to set an initial model value asynchronously.
250252
- If the initial model value is available at runtime, prefer setting it as part of the `initialState` of the `modelReducer` instead.
251-
- This is equivalent to calling `actions.change(model, value, { silent: true })`.
253+
- This is different than calling `actions.change(model, value, { silent: true })`. Both are similar with one main difference: `actions.load` also updates the `.loadedValue`, whereas a silent change does not.
252254

253255
<h2 id="actions-omit"></h2>
254256
## `actions.omit(model, props)`

src/components/form-component.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ function createFormClass(s = defaultStrategy) {
150150

151151
if (!formValue) return;
152152

153+
window.c = window.c || 1;
154+
153155
if (!validators && !errors && (modelValue !== nextProps.modelValue)) {
156+
console.log(c, 'here');
157+
if (window.c++ > 50) return;
154158
// If the form is invalid (due to async validity)
155159
// but its fields are valid and the value has changed,
156160
// the form should be "valid" again.

test/control-component-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ Object.keys(testContexts).forEach((testKey) => {
20292029
});
20302030
});
20312031

2032-
describe('non-string/numeric values for custom controls', () => {
2032+
describe('non-string values for custom controls', () => {
20332033
const initialState = getInitialState({
20342034
extraData: { address: '221B Baker Street' },
20352035
});

0 commit comments

Comments
 (0)