Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useRequest Warning: Can't perform a React state update on a component that hasn't mounted yet. #2356

Open
mao437303994 opened this issue Nov 5, 2023 · 13 comments
Labels
help wanted Extra attention is needed

Comments

@mao437303994
Copy link

微信图片_20231105232857
这个问题没人遇到吗?获取到数据之前组件已经被卸载了,内部依旧调用useUpdate()导致报错

@liuyib
Copy link
Collaborator

liuyib commented Nov 6, 2023

React has removed this warning in v18, please see: reactwg/react-18#82

In React < v18, please ignore this warning.

@liuyib liuyib closed this as completed Nov 6, 2023
@alvin0216
Copy link

React 18.2.0 并没有解决

@SignDawn
Copy link

来给个 demo ?具体问题具体分析

@liuyib
Copy link
Collaborator

liuyib commented Feb 26, 2024

截图的报错和 reactwg/react-18#82 里的报错:

Warning: 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.

好像不是同一个问题,后面再看下

@liuyib liuyib reopened this Feb 26, 2024
@crazylxr
Copy link
Collaborator

@mao437303994 来个 demo 呢

@crazylxr crazylxr added the 🤔 Need Reproduce We cannot reproduce your problem label Apr 21, 2024
Copy link

Hello @mao437303994. Please provide a online reproduction by forking this link https://codesandbox.io/s/ok2fe or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 3 days.

你好 @mao437303994, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
@liuyib
Copy link
Collaborator

liuyib commented Apr 30, 2024

@1zilc 多谢提供 demo,但是没有复现
image

@zhengmenghuang
Copy link

zhengmenghuang commented May 24, 2024

React 18.3.3 在使用 useRequest 也遇到了一样的问题
const { data: areaOptions } = useRequest(async () => await GetAreaList(), { cacheKey: 'cacheKey-area-list' });

@linxianxi
Copy link

+1

@crazylxr crazylxr reopened this Jul 24, 2024
@crazylxr crazylxr added help wanted Extra attention is needed and removed 🤔 Need Reproduce We cannot reproduce your problem labels Jul 24, 2024
Copy link

Hello @mao437303994. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to proper branch (feature branch for the new feature, master for bugfix and other changes), fill the Pull Request Template here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!

你好 @mao437303994,我们完全同意你的提议/反馈,欢迎直接在此仓库 创建一个 Pull Request 来解决这个问题。请将 Pull Request 发到正确的分支(新特性发到 feature 分支,其他发到 master 分支),务必填写 Pull Request 内的预设模板,提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review,提前感谢和期待您的贡献。

giphy

@linxianxi
Copy link

好像是设置了 cacheKey 就会有这个问题

@linxianxi
Copy link

same #1866

@leonkong
Copy link

leonkong commented Sep 5, 2024

好像是设置了 cacheKey 就会有这个问题

确认,设置了cacheKey就会有问题,注释掉就没问题。React 18.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants