-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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在严格模式StrictMode下,缓存失效 #2526
Comments
Maybe you need to set it to not expire or staleTime |
|
I don't. But it's work. |
@zhangmo8 actually, we are not on the same page. I need refresh the datas, but if I set staleTime to -1, the refresh is invalid. |
ok. 我知道啦...英文描述比较麻烦... 你的问题其实是在于,非严格模式下,它两个数据是同步的,而严格模式下并没有同步更新,我认为它可能是react的render策略引起的问题 语言描述比较苍白,为此,我录制了一个视频来描述这个行为。并且更改了请求时间为5s,以便你能够更好的看到它读取缓存的数据 Screen.Recording.2024-04-24.at.11.00.37.mov另外附上链接 Preview |
OK got it, 其实我想说的就是这个问题,如果开启StrictMode,就只能手动去refresh了 |
所以,感觉是应该去给 React 提交 issues,或者采用 抽离状态,memo等方式阻止它的更新,来保持和严格模式下的表现一致,以便你在开发环境的表现行为和打包后的表现行为一致。 当然,如果你是拉磨,我更推荐去除严格模式 |
严格模式下的行为,确实和官网预期的不一样。看来严格模式下的单测有点问题 |
Preview
The text was updated successfully, but these errors were encountered: