2017-09-28 61 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中。

你爲什麼要這麼做?也許,你應該渲染組件,然後使其可見或不可見。這是最簡單的方法。

再見

相關問題