Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function objectKeysHaveChanged(formData, state) {
// for performance, first check for lengths
const newKeys = Object.keys(formData);
const oldKeys = Object.keys(state);
if (newKeys.length < oldKeys.length) {
return true;
}
// deep check on sorted keys
if (!deepEquals(newKeys.sort(), oldKeys.sort())) {
return true;
}
return false;
}
return runRules(formData).then(conf => {
let dataChanged = !deepEquals(this.formData, conf.formData);
this.formData = conf.formData;
let newState = { schema: conf.schema, uiSchema: conf.uiSchema };
let confChanged = !deepEquals(newState, this.state);
if (dataChanged || confChanged) {
this.shouldUpdate = true;
this.setState(newState);
}
return conf;
});
}
field => !deepEquals(formData[field], changedFormData[field])
);
componentWillReceiveProps(nextProps) {
let formDataChanged =
nextProps.formData && !deepEquals(nextProps.formData, this.formData);
if (formDataChanged) {
this.updateConf(nextProps.formData);
this.shouldUpdate = true;
} else {
this.shouldUpdate =
this.shouldUpdate ||
!deepEquals(
nextProps,
Object.assign({}, this.props, { formData: nextProps.formData })
);
}
}
).then(conf => {
if (deepEquals(conf.formData, formData)) {
return conf;
} else {
return doRunRules(
engine,
conf.formData,
schema,
uiSchema,
extraActions
);
}
});
};
shouldComponentUpdate(nextProps) {
return !deepEquals(this.props, nextProps);
}
if (formData.some(v => deepEquals(v, newVal))) {
return formData;
componentWillReceiveProps(nextProps) {
let formDataChanged =
nextProps.formData && !deepEquals(nextProps.formData, this.formData);
if (formDataChanged) {
this.updateConf(nextProps.formData);
this.shouldUpdate = true;
} else {
this.shouldUpdate =
this.shouldUpdate ||
!deepEquals(
nextProps,
Object.assign({}, this.props, { formData: nextProps.formData })
);
}
}