allow user to return nothing in submitCallback

Useful when the callback is meant for side effect and not for modifying the data
This commit is contained in:
Eric Burel 2018-09-05 17:08:29 +02:00
parent 5427e994b0
commit 755d5f6ad0

View file

@ -227,7 +227,7 @@ class SmartForm extends Component {
- Nested array item: 'addresses.1.city' - Nested array item: 'addresses.1.city'
*/ */
compactParent(data, path); compactParent(data, path);
} }
}); });
@ -572,10 +572,10 @@ class SmartForm extends Component {
// default to overwriting old value with new // default to overwriting old value with new
const { mode = 'overwrite' } = options; const { mode = 'overwrite' } = options;
// keep the previous ones and extend (with possible replacement) with new ones // keep the previous ones and extend (with possible replacement) with new ones
this.setState(prevState => { this.setState(prevState => {
// keep only the relevant properties // keep only the relevant properties
const { currentValues, currentDocument, deletedValues } = cloneDeep(prevState); const { currentValues, currentDocument, deletedValues } = cloneDeep(prevState);
const newState = { currentValues, currentDocument, deletedValues, foo: {} }; const newState = { currentValues, currentDocument, deletedValues, foo: {} };
@ -811,7 +811,7 @@ class SmartForm extends Component {
// if there's a submit callback, run it // if there's a submit callback, run it
if (this.props.submitCallback) { if (this.props.submitCallback) {
data = this.props.submitCallback(data); data = this.props.submitCallback(data) || data;
} }
if (this.getFormType() === 'new') { if (this.getFormType() === 'new') {