Javascript React Dev Tools setInProps

Javascript React Dev Tools setInProps,javascript,reactjs,ecmascript-6,react-props,Javascript,Reactjs,Ecmascript 6,React Props,我一直在研究React开发工具,并将它们的一些代码用于我自己的项目。我无法理解方法中的路径应该是什么: 然后copyWithSetImpl(…): 有人能举个例子说明我如何使用setInProps更新道具中的内容吗?我已经有了内部实例对象,并假设value只是prop值 function setInProps(internalInst, forceUpdate, path: Array<string | number>, value: any) { var element = i

我一直在研究React开发工具,并将它们的一些代码用于我自己的项目。我无法理解方法中的
路径应该是什么:

然后
copyWithSetImpl(…)

有人能举个例子说明我如何使用
setInProps
更新道具中的内容吗?我已经有了内部实例对象,并假设
value
只是prop值

function setInProps(internalInst, forceUpdate, path: Array<string | number>, value: any) {
  var element = internalInst._currentElement;
  internalInst._currentElement = {
    ...element,
    props: copyWithSet(element.props, path, value),
  };
  forceUpdate.call(internalInst._instance);
}
function copyWithSet(obj: Object | Array<any>, path: Array<string | number>, value: any): Object | Array<any> {
  return copyWithSetImpl(obj, path, 0, value);
}
function copyWithSetImpl(obj, path, idx, value) {
  if (idx >= path.length) {
    return value;
  }
  var key = path[idx];
  var updated = Array.isArray(obj) ? obj.slice() : {...obj};
  // $FlowFixMe number or string is fine here
  updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
  return updated;
}