MCPcopy Create free account
hub / github.com/react/react / copyWithDeleteImpl

Function copyWithDeleteImpl

packages/react-reconciler/src/ReactFiberReconciler.js:608–626  ·  view source on GitHub ↗
(
    obj: Object | Array<any>,
    path: Array<string | number>,
    index: number,
  )

Source from the content-addressed store, hash-verified

606
607if (__DEV__) {
608 const copyWithDeleteImpl = (
609 obj: Object | Array<any>,
610 path: Array<string | number>,
611 index: number,
612 ): $FlowFixMe => {
613 const key = path[index];
614 const updated = isArray(obj) ? obj.slice() : {...obj};
615 if (index + 1 === path.length) {
616 if (isArray(updated)) {
617 updated.splice(((key: any): number), 1);
618 } else {
619 delete updated[key];
620 }
621 return updated;
622 }
623 // $FlowFixMe[incompatible-use] number or string is fine here
624 updated[key] = copyWithDeleteImpl(obj[key], path, index + 1);
625 return updated;
626 };
627
628 const copyWithDelete = (
629 obj: Object | Array<any>,

Callers 1

copyWithDeleteFunction · 0.85

Calls 1

isArrayFunction · 0.85

Tested by

no test coverage detected