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

Function deletePath

packages/react-devtools-shared/src/backend/legacy/renderer.js:973–1005  ·  view source on GitHub ↗
(
    type: 'context' | 'hooks' | 'props' | 'state',
    id: number,
    hookID: ?number,
    path: Array<string | number>,
  )

Source from the content-addressed store, hash-verified

971 }
972
973 function deletePath(
974 type: 'context' | 'hooks' | 'props' | 'state',
975 id: number,
976 hookID: ?number,
977 path: Array<string | number>,
978 ): void {
979 const internalInstance = idToInternalInstanceMap.get(id);
980 if (internalInstance != null) {
981 const publicInstance = internalInstance._instance;
982 if (publicInstance != null) {
983 switch (type) {
984 case 'context':
985 deletePathInObject(publicInstance.context, path);
986 forceUpdate(publicInstance);
987 break;
988 case 'hooks':
989 throw new Error('Hooks not supported by this renderer');
990 case 'props':
991 const element = internalInstance._currentElement;
992 internalInstance._currentElement = {
993 ...element,
994 props: copyWithDelete(element.props, path),
995 };
996 forceUpdate(publicInstance);
997 break;
998 case 'state':
999 deletePathInObject(publicInstance.state, path);
1000 forceUpdate(publicInstance);
1001 break;
1002 }
1003 }
1004 }
1005 }
1006
1007 function renamePath(
1008 type: 'context' | 'hooks' | 'props' | 'state',

Callers

nothing calls this directly

Calls 4

deletePathInObjectFunction · 0.90
forceUpdateFunction · 0.90
copyWithDeleteFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected