@@ -48,9 +48,17 @@ var actionTypes = {
4848
4949exports . actionTypes = actionTypes ;
5050
51+ /**
52+ * Is field registered.
53+ */
54+ function isFieldRegistered ( action , state ) {
55+ return action . type === actionTypes . REGISTER_FIELD && state . fields . meta [ action . payload . field ] ;
56+ }
5157/**
5258 * Values reducer.
5359 */
60+
61+
5462var valuesReducer = function valuesReducer ( state , action ) {
5563 var payload = action . payload ,
5664 type = action . type ;
@@ -66,6 +74,10 @@ var valuesReducer = function valuesReducer(state, action) {
6674 newValue = payload . value ;
6775 }
6876
77+ if ( newValue === state [ payload . field ] ) {
78+ return state ;
79+ }
80+
6981 return _objectSpread ( { } , state , _defineProperty ( { } , payload . field , newValue ) ) ;
7082 }
7183
@@ -85,6 +97,8 @@ var valuesReducer = function valuesReducer(state, action) {
8597
8698
8799var metaReducer = function metaReducer ( state , action ) {
100+ var _state$payload$field ;
101+
88102 var payload = action . payload ,
89103 type = action . type ;
90104
@@ -96,6 +110,10 @@ var metaReducer = function metaReducer(state, action) {
96110 } ) ) ) ;
97111
98112 case actionTypes . SET_FIELD_VALUE :
113+ if ( ( _state$payload$field = state [ payload . field ] ) === null || _state$payload$field === void 0 ? void 0 : _state$payload$field . dirty ) {
114+ return state ;
115+ }
116+
99117 return _objectSpread ( { } , state , _defineProperty ( { } , payload . field , _objectSpread ( { } , state [ payload . field ] , {
100118 dirty : true
101119 } ) ) ) ;
@@ -209,11 +227,15 @@ function isSubmittingReducer(state, action) {
209227
210228var formReducer = function formReducer ( validate , stateReducer ) {
211229 return function ( state , action ) {
230+ if ( isFieldRegistered ( action , state ) ) {
231+ return state ;
232+ }
233+
212234 var fieldsValues = valuesReducer ( state . fields . values , action ) ;
213235 var fieldsMeta = metaReducer ( state . fields . meta , action ) ;
214236 var isSubmitting = isSubmittingReducer ( state . isSubmitting , action ) ;
215237 var submitStatus = submitStatusReducer ( state . submitStatus , action ) ;
216- var fieldsErrors = errorsReducer ( {
238+ var fieldsErrors = fieldsValues === state . fields . values ? state . fields . errors : errorsReducer ( {
217239 action : action ,
218240 state : state . fields . errors ,
219241 validate : validate ,
0 commit comments