MCPcopy
hub / github.com/facebook/react / copyWithSetImpl

Function copyWithSetImpl

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

Source from the content-addressed store, hash-verified

684 };
685
686 const copyWithSetImpl = (
687 obj: Object | Array<any>,
688 path: Array<string | number>,
689 index: number,
690 value: any,
691 ): $FlowFixMe => {
692 if (index >= path.length) {
693 return value;
694 }
695 const key = path[index];
696 const updated = isArray(obj) ? obj.slice() : {...obj};
697 // $FlowFixMe[incompatible-use] number or string is fine here
698 updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
699 return updated;
700 };
701
702 const copyWithSet = (
703 obj: Object | Array<any>,

Callers 1

copyWithSetFunction · 0.85

Calls 1

isArrayFunction · 0.85

Tested by

no test coverage detected