我正在使用mobx并将钩子一起反应。我有一个useContext来获取存储功能
const store = useContext(MyStore)
useEffect(() => {
if (init !== '') {
store.loading = true;
store.bulkApprove(init).then(data => {
store.unCheckAll();
});
}
}, [init]);
我可以看到类似以下的警告
React Hook useEffect has a missing dependency: 'store'. Either include it or remove the dependency array
我真的很困惑,为什么我需要在依赖项数组中包括存储
[React Hook useEffect has a missing dependency: <dep>. Either include it or remove the dependency array
仅仅意味着短绒棉签警告您,您的依赖项依赖于可能改变的外部值。
store
已订阅上下文MyStore
。表示它正在跟踪其更改。