Skip to content

Commit 3f235c8

Browse files
committed
Clear form cache on componentDidMount instead of mapStateToProps (davidkpiano#1218)
1 parent 877b08a commit 3f235c8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: src/components/form-component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function createFormClass(s = defaultStrategy) {
9898
if (this.props.getDispatch) {
9999
this.props.getDispatch(this.props.dispatch);
100100
}
101+
clearGetFormCacheForModel(this.props.model);
101102
}
102103

103104
UNSAFE_componentWillReceiveProps(nextProps) {
@@ -409,7 +410,6 @@ function createFormClass(s = defaultStrategy) {
409410

410411
function mapStateToProps(state, { model }) {
411412
const modelString = getModel(model, state);
412-
clearGetFormCacheForModel(modelString);
413413
const form = s.getForm(state, modelString);
414414

415415
invariant(form,

Diff for: test/form-component-spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import sinon from 'sinon';
1111

1212
import isValid from '../src/form/is-valid';
1313
import { defaultTestContexts, testCreateStore, testRender } from './utils';
14+
import { clearGetFormCache } from '../src/utils/get-form';
1415

1516
import {
1617
Form as _Form,
@@ -69,6 +70,10 @@ Object.keys(testContexts).forEach((testKey) => {
6970
const combineForms = testContext.combineForms;
7071

7172
describe(`<Form> component (${testKey} context)`, () => {
73+
beforeEach(() => {
74+
clearGetFormCache();
75+
});
76+
7277
describe('wraps component if specified', () => {
7378
const store = testCreateStore({
7479
testForm: formReducer('test', object),

0 commit comments

Comments
 (0)