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

Commit 5588a64

Browse files
committed
Removing deprecation warnings
1 parent b9a4eaa commit 5588a64

File tree

1 file changed

+17
-64
lines changed

1 file changed

+17
-64
lines changed

src/reducers/form-reducer.js

Lines changed: 17 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,15 @@ import flatten from 'flat';
1313
import actionTypes from '../action-types';
1414
import { isValid } from '../utils';
1515

16-
const propInverses = {
17-
blur: 'focus',
18-
dirty: 'pristine',
19-
untouched: 'touched',
20-
};
21-
22-
function deprecateProp(prop, result) {
23-
console.warn(`The .${prop} prop will be deprecated as of v1.0.`
24-
+ `Please use the the inverse of .${propInverses[prop]} instead.`);
25-
26-
return result;
27-
}
28-
2916
const initialFieldState = {
30-
get blur() {
31-
return deprecateProp('blur', true);
32-
},
33-
get dirty() {
34-
return deprecateProp('dirty', false);
35-
},
17+
blur: true, // will be deprecated
18+
dirty: false, // will be deprecated
3619
focus: false,
3720
pending: false,
3821
pristine: true,
3922
submitted: false,
4023
touched: false,
41-
get untouched() {
42-
return deprecateProp('untouched', true);
43-
},
24+
untouched: true, // will be deprecated
4425
valid: true,
4526
validating: false,
4627
viewValue: null,
@@ -164,40 +145,30 @@ function _createFormReducer(model, initialState) {
164145

165146
case actionTypes.FOCUS:
166147
return setField(state, localPath, {
167-
get blur() {
168-
return deprecateProp('blur', false);
169-
},
148+
blur: false, // will be deprecated
170149
focus: true,
171150
});
172151

173152
case actionTypes.CHANGE: {
174153
const setDirtyState = icepick.merge(state, {
175-
get dirty() {
176-
return deprecateProp('dirty', true);
177-
},
154+
dirty: true, // will be deprecated
178155
pristine: false,
179156
});
180157

181158
return removeDiff(setField(setDirtyState, localPath, {
182-
get dirty() {
183-
return deprecateProp('dirty', true);
184-
},
159+
dirty: true, // will be deprecated
185160
pristine: false,
186161
}), action.value, localPath);
187162
}
188163

189164
case actionTypes.SET_DIRTY: {
190165
const setDirtyState = icepick.merge(state, {
191-
get dirty() {
192-
return deprecateProp('dirty', true);
193-
},
166+
dirty: true, // will be deprecated
194167
pristine: false,
195168
});
196169

197170
return setField(setDirtyState, localPath, {
198-
get dirty() {
199-
return deprecateProp('dirty', true);
200-
},
171+
dirty: true, // will be deprecated
201172
pristine: false,
202173
});
203174
}
@@ -208,19 +179,13 @@ function _createFormReducer(model, initialState) {
208179
focus: false,
209180
touched: true,
210181
retouched: state.submitted || state.submitFailed,
211-
get blur() {
212-
return deprecateProp('blur', true);
213-
},
214-
get untouched() {
215-
return deprecateProp('untouched', false);
216-
},
182+
blur: true, // will be deprecated
183+
untouched: false, // will be deprecated
217184
});
218185

219186
return icepick.merge(fieldState, {
220187
touched: true,
221-
get untouched() {
222-
return deprecateProp('untouched', false);
223-
},
188+
untouched: false, // will be deprecated
224189
});
225190
}
226191

@@ -360,37 +325,29 @@ function _createFormReducer(model, initialState) {
360325
setPristineState = icepick.merge(state, {
361326
fields: mapValues(state.fields, field => ({
362327
...field,
363-
get dirty() {
364-
return deprecateProp('dirty', false);
365-
},
328+
dirty: false, // will be deprecated
366329
pristine: true,
367330
})),
368331
});
369332
} else {
370333
setPristineState = setField(state, localPath, {
371-
get dirty() {
372-
return deprecateProp('dirty', false);
373-
},
334+
dirty: false, // will be deprecated
374335
pristine: true,
375336
});
376337

377338
formIsPristine = every(mapValues(setPristineState.fields, field => field.pristine));
378339
}
379340

380341
return icepick.merge(setPristineState, {
381-
get dirty() {
382-
return deprecateProp('dirty', !formIsPristine);
383-
},
342+
dirty: !formIsPristine, // will be deprecated
384343
pristine: formIsPristine,
385344
});
386345
}
387346

388347
case actionTypes.SET_UNTOUCHED:
389348
return setField(state, localPath, {
390349
touched: false,
391-
get untouched() {
392-
return deprecateProp('untouched', true);
393-
},
350+
untouched: true, // will be deprecated
394351
});
395352

396353
case actionTypes.SET_SUBMITTED:
@@ -399,9 +356,7 @@ function _createFormReducer(model, initialState) {
399356
submitted: !!action.submitted,
400357
submitFailed: false,
401358
touched: true,
402-
get untouched() {
403-
return deprecateProp('untouched', false);
404-
},
359+
untouched: false, // will be deprecated
405360
});
406361

407362
case actionTypes.SET_SUBMIT_FAILED:
@@ -410,9 +365,7 @@ function _createFormReducer(model, initialState) {
410365
submitted: false,
411366
submitFailed: true,
412367
touched: true,
413-
get untouched() {
414-
return deprecateProp('untouched', false);
415-
},
368+
untouched: false, // will be deprecated
416369
});
417370

418371
case actionTypes.SET_INITIAL:

0 commit comments

Comments
 (0)