From 3f235c87fceb9a7816f28ce1b57199190c9dd989 Mon Sep 17 00:00:00 2001 From: Andrew Tam Date: Tue, 24 Mar 2020 21:14:57 -0400 Subject: [PATCH 1/3] Clear form cache on `componentDidMount` instead of `mapStateToProps` (#1218) --- src/components/form-component.js | 2 +- test/form-component-spec.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/form-component.js b/src/components/form-component.js index 49dc6881e..42ebd57e7 100644 --- a/src/components/form-component.js +++ b/src/components/form-component.js @@ -98,6 +98,7 @@ function createFormClass(s = defaultStrategy) { if (this.props.getDispatch) { this.props.getDispatch(this.props.dispatch); } + clearGetFormCacheForModel(this.props.model); } UNSAFE_componentWillReceiveProps(nextProps) { @@ -409,7 +410,6 @@ function createFormClass(s = defaultStrategy) { function mapStateToProps(state, { model }) { const modelString = getModel(model, state); - clearGetFormCacheForModel(modelString); const form = s.getForm(state, modelString); invariant(form, diff --git a/test/form-component-spec.js b/test/form-component-spec.js index 712d8c952..b7064dfc2 100644 --- a/test/form-component-spec.js +++ b/test/form-component-spec.js @@ -11,6 +11,7 @@ import sinon from 'sinon'; import isValid from '../src/form/is-valid'; import { defaultTestContexts, testCreateStore, testRender } from './utils'; +import { clearGetFormCache } from '../src/utils/get-form'; import { Form as _Form, @@ -69,6 +70,10 @@ Object.keys(testContexts).forEach((testKey) => { const combineForms = testContext.combineForms; describe(`
component (${testKey} context)`, () => { + beforeEach(() => { + clearGetFormCache(); + }); + describe('wraps component if specified', () => { const store = testCreateStore({ testForm: formReducer('test', object), From ce4a25562b86c3ee0019da7515ef46aadf5a9506 Mon Sep 17 00:00:00 2001 From: Andrew Tam Date: Wed, 25 Mar 2020 08:36:12 -0400 Subject: [PATCH 2/3] Running `yarn install` to fix lock-file issues on CI --- yarn.lock | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 42a2fa46f..7313e391b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2588,6 +2588,11 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" +"js-tokens@^3.0.0 || ^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + js-yaml@^3.5.1: version "3.11.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef" @@ -2719,7 +2724,7 @@ loader-utils@^1.0.2: emojis-list "^2.0.0" json5 "^0.5.0" -lodash-es@^4.17.5, lodash-es@^4.2.1: +lodash-es@^4.17.5: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.10.tgz#62cd7104cdf5dd87f235a837f0ede0e8e5117e05" @@ -2792,7 +2797,7 @@ lodash.words@^3.0.0: dependencies: lodash._root "^3.0.0" -lodash@^4.0.0, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@~4.17.2: +lodash@^4.0.0, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.3.0, lodash@~4.17.2: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" @@ -2810,6 +2815,13 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1: dependencies: js-tokens "^3.0.0" +loose-envify@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + lru-cache@2: version "2.7.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" @@ -3745,14 +3757,13 @@ redux-thunk@^2.0.1: version "2.2.0" resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.2.0.tgz#e615a16e16b47a19a515766133d1e3e99b7852e5" -redux@^3.3.1: - version "3.7.2" - resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b" +redux@^4.0.0: + version "4.0.5" + resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" + integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w== dependencies: - lodash "^4.2.1" - lodash-es "^4.2.1" - loose-envify "^1.1.0" - symbol-observable "^1.0.3" + loose-envify "^1.4.0" + symbol-observable "^1.2.0" regenerate@^1.2.1: version "1.3.3" @@ -4187,9 +4198,10 @@ svgo@^0.7.0: sax "~1.2.1" whet.extend "~0.9.9" -symbol-observable@^1.0.3: +symbol-observable@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" + integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== symbol-tree@^3.2.1: version "3.2.2" From 488eb9ecbbe6dd648bbea7c290b98a67b8e52e9a Mon Sep 17 00:00:00 2001 From: Andrew Tam Date: Wed, 25 Mar 2020 08:53:32 -0400 Subject: [PATCH 3/3] Also fixing some broken lint tests --- src/components/control-component-factory.js | 13 +++++++------ src/components/form-component.js | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/control-component-factory.js b/src/components/control-component-factory.js index a27a7af55..fc7cbd789 100644 --- a/src/components/control-component-factory.js +++ b/src/components/control-component-factory.js @@ -157,12 +157,6 @@ function createControlClass(s) { this.handleLoad(); } - UNSAFE_componentWillReceiveProps({ modelValue }) { - if (modelValue !== this.props.modelValue) { - this.setViewValue(modelValue); - } - } - shouldComponentUpdate(nextProps, nextState) { return !shallowEqual(this.props, nextProps, { deepKeys: ['controlProps'], @@ -388,6 +382,13 @@ function createControlClass(s) { return this.props.getValue(event, this.props); } + /* eslint-disable camelcase */ + UNSAFE_componentWillReceiveProps({ modelValue }) { + if (modelValue !== this.props.modelValue) { + this.setViewValue(modelValue); + } + } + handleIntents() { const { model, diff --git a/src/components/form-component.js b/src/components/form-component.js index 42ebd57e7..2ddd645df 100644 --- a/src/components/form-component.js +++ b/src/components/form-component.js @@ -101,12 +101,6 @@ function createFormClass(s = defaultStrategy) { clearGetFormCacheForModel(this.props.model); } - UNSAFE_componentWillReceiveProps(nextProps) { - if (containsEvent(nextProps.validateOn, 'change')) { - this.validate(nextProps); - } - } - shouldComponentUpdate(nextProps, nextState) { return deepCompareChildren(this, nextProps, nextState); } @@ -123,6 +117,13 @@ function createFormClass(s = defaultStrategy) { } } + /* eslint-disable camelcase */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (containsEvent(nextProps.validateOn, 'change')) { + this.validate(nextProps); + } + } + handleUpdate() { if (this.props.onUpdate) { this.props.onUpdate(this.props.formValue);