Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
<span> {
dispatch(
update(
parentPath,
array => {
const copy = array.slice();
return _.filter(copy, el => !_.isEqual(el, data))
}
)
)
}}>
{'\u274C'}</span>
private addToRoot() {
const { schema, dispatch, path } = this.props;
if (isNotTuple(schema)) {
dispatch(
update(
path,
data => {
const clone = data.slice();
clone.push({});
return clone;
}
)
);
}
}
onClick={() => {
const newData = _.keys(prop.schema.properties).reduce(
(d, key) => {
if (prop.schema.properties[key].default) {
d[key] = prop.schema.properties[key].default;
}
return d;
},
{}
);
dispatch(
update(
compose(this.state.dialog.path, prop.property),
array => {
if (_.isEmpty(array)) {
return [newData];
}
array.push(newData);
return array;
}
)
);
this.closeDialog();
}}
>
const addNewItem = (dispatch, path: string) => {
const element = {};
dispatch(
update(
path,
array => {
if (array === undefined || array === null) {
return [element];
}
const clone = _.clone(array);
clone.push(element);
return clone;
}
)
);
};