在获取承诺后在导航上反应内存泄漏

时间:2019-11-14 17:07:39

标签: javascript reactjs memory frameworks

我有这个问题:

Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

我到底在做什么。

fetch(url, { signal }).then( ... ).finally(()=> navigate(`/blog/${query}`)

该信号来自AbortController,Jake Archibald在这里推荐了该信号:https://developers.google.com/web/updates/2017/09/abortable-fetch,但它完全没有帮助。谁能告诉我哪里出了问题?假设状态在路由之前发生变化,这就是一个问题。但是如何在不更改路由的情况下向URL添加一些参数,而不是导航到它呢?

0 个答案:

没有答案
相关问题