2017-09-28 89 views
0

我假设包react-virtual-list在使用VirtualList时调用setState,但这不应该导致componentDidMount内部的问题吧?为什么在ComponentDidMount中调用setState会导致错误?

Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the vlist component.

componentDidMount =() => { this.MyVirtualList = VirtualList({container: this._itemsList})(this.MyList) }

+0

你能发布组成你的组件的代码吗? – djfdev

+0

什么是'''this.MyVirtualList'''?这是一个功能?请展示更多代码。 –

回答

0

你是 “初始化” 组件到一个变量,但你不安装它。

要装入组件,组件应该位于render方法中,否则该组件将不会安装在DOM中。

你为什么要这么做?也许,你应该渲染组件,然后使其可见或不可见。这是最简单的方法。

再见

相关问题