Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react组件刷新时引发错误_Reactjs_Typescript - Fatal编程技术网

Reactjs react组件刷新时引发错误

Reactjs react组件刷新时引发错误,reactjs,typescript,Reactjs,Typescript,我有一个react-typescript组件,它具有以下componentDidMount方法: componentDidMount() { ComponentFields.get(this.ComponentName) .then(activeFields => { this.setState({ activeFields }); }); } 它有一个与以下字段的状态接口 export interface ISetting

我有一个react-typescript组件,它具有以下componentDidMount方法:

componentDidMount() {
    ComponentFields.get(this.ComponentName)
        .then(activeFields => {
            this.setState({ activeFields });
        });
}
它有一个与以下字段的状态接口

export interface ISettingsPageState {
    activeFields: Dictionary<IComponentField>,
}
导出接口正在设置{
活动字段:字典,
}
其中,
IComponentField
是一个接口。
ComponentFields.get(componentName:string)
是一个静态方法,返回一个
Promise

它在第一次加载时工作正常,但当我刷新页面时,
componentDidMount
中的
setState
方法抛出以下异常:

未捕获的DomeException:未能在“节点”上执行“insertBefore”:要在其之前插入新节点的节点不是此节点的子节点


有人知道这是什么原因吗?

原来是子组件抛出了错误。尽管异常是在
setState
行抛出的,但问题出在我的
render
方法中。如果有人有同样的问题,我建议大家看一下
render
方法,看看哪里出了问题。

问题没有。发布的代码没有解释什么是错误的。谢谢,这个例子不符合mcve标准的事实实际上是我需要找出哪里出了问题的提示。看到我的答案了。是的,当你解剖它们来提供MCVE时,很多案例都会自行解决。