我有一个自定义的 React Fiber Reconciler,我使用react-reconciler
包中的默认导出创建它。在 ReactDOM 组件中,我执行
this.mountNode = CustomRenderer.createContainer(this.stage)
CustomRenderer.updateContainer(
<SomeContextProvider>{children}<SomeContextProvider/>,
this.mountNode,
this
)
但是,当我打开 React devtools 时,我得到
Uncaught TypeError: Cannot read property 'replace' of null in the getDataFiber method here:
case HostComponent:
nodeType = 'Native';
name = fiber.type;
// TODO (bvaughn) we plan to remove this prefix anyway.
// We can cut this special case out when it's gone.
name = name.replace('topsecret-', ''); /////////// Error here on this line
这似乎是因为fiber.type
为空。环顾四周,我看到人们将类型作为第二个参数传递给他们的渲染器的 createContainer,但是这样做给了我一个奇怪且看似无关的错误
Uncaught TypeError: scheduleDeferredCallback is not a function
Uncaught TypeError: cancelDeferredCallback is not a function
,所以这可能不是正确的做法。
主机配置很长,所以这里有一个要点:https ://gist.github.com/arilotter/d34c684da13a4825285ddfe021ec4be3
这是我的package.json
:
https ://gist.github.com/arilotter/fd53712900f726a46c1d9a6ceeaf151c
我可以在哪里type
为我的容器指定,以便 devtools 工作?