Mobx超出范围读取:2 -React-天然

k4ymrczo  于 2022-12-19  发布在  React
关注(0)|答案(1)|浏览(152)

我在我的React原生应用程序中使用我的mobx。

移动x:“^6.6.2”,移动x-React-简化:“^3.4.0”,

mobxStore.js

this.arr = [];

getArray(){
   return this.arr;
}

const temp = appState.getArray();

在获取状态数组时,我多次收到此警告。
我想从mobx中删除此多行警告。谢谢您的支持。

dgiusagp

dgiusagp1#

我得到这个错误,因为许多天,并搜索了很多,以消除这个警告,最后我找到了解决方案,在这里,我们去。

const temp = appState.getArray().slice();

const temp = appState.arr.slice();

这个**slice()**函数将把它们全部删除。

相关问题