From d4b99f6dcaae5ff5b9d0aaf93c917b00c336d362 Mon Sep 17 00:00:00 2001 From: Matt C Date: Thu, 23 Feb 2017 12:40:50 +1100 Subject: [PATCH] [redux-form] Added an optional "forceUnregisterOnUnmount" property to the "reduxForm()" "Config" interface, as it is present in the redux-form API. --- redux-form/lib/reduxForm.d.ts | 6 ++++++ redux-form/redux-form-tests.tsx | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/redux-form/lib/reduxForm.d.ts b/redux-form/lib/reduxForm.d.ts index 82efbd9cff..bcfafe2e3a 100644 --- a/redux-form/lib/reduxForm.d.ts +++ b/redux-form/lib/reduxForm.d.ts @@ -65,6 +65,12 @@ export interface Config { */ destroyOnUnmount?: boolean; + /** + * Whether or not to force unregistration of fields -- use in conjunction + * with destroyOnUnmount. + */ + forceUnregisterOnUnmount?: boolean; + /** * A function that takes the entire Redux state and returns the state slice * which corresponds to where the redux-form reducer was mounted. This diff --git a/redux-form/redux-form-tests.tsx b/redux-form/redux-form-tests.tsx index e660b6b0b5..f37e1e9815 100644 --- a/redux-form/redux-form-tests.tsx +++ b/redux-form/redux-form-tests.tsx @@ -56,3 +56,22 @@ const MyStatelessFunctionalComponent: React.SFC = () =>
; reduxForm({ form: 'mySFCForm' })(MyStatelessFunctionalComponent); + +class MyReusableForm extends Component { + render() { + return ( +
+ +
+ ); + } +} + +reduxForm({ + form: 'forceUnregisterOnMountForm', + forceUnregisterOnUnmount: true +});