RTK查询会将所有数据存储吗?如果是,为什么还需要将数据放入切片中?

发布于 2025-01-22 18:59:30 字数 659 浏览 1 评论 0原文

我的问题将基于此示例: https://codesandbox.io/s/github/reduxjs/redux-toolkit/redux-toole/tree/master/master/exampleas/query/react/react/react/authentication-windation-windication-with-with-with-extrareducers?from? -embed =& file =/src/app/services/auth.ts

不知道如何使用使用use -elector,我不知道为什么您需要创建,您需要创建Authslice并将令牌存储到authstate中,如果RTK查询将所有数据放入商店/状态?

先感谢您

My question will be based on this example:
https://codesandbox.io/s/github/reduxjs/redux-toolkit/tree/master/examples/query/react/authentication-with-extrareducers?from-embed=&file=/src/app/services/auth.ts

Without knowing how to access the data fetched from RTK query using useSelector, I wonder why do you need to create authSlice and store the token into the AuthState, if RTK query put all the data into store/state?

Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦年海沫深 2025-01-29 18:59:30

因为RTK查询不仅将数据放入商店中 - 还可以将它们删除。

60秒后,将删除您的应用程序未使用的查询缓存条目。
一旦突变组件卸下或触发另一个突变(因为在那时,就无法再获取数据。

因此数据并将其放置在某个地方,您会再次找到它,可以决定自己是否要删除。

Because RTK Query not only puts data into the store - it also removes them there.

A query cache entry that is not being used by your app any more will be removed after 60 seconds.
A mutation result will be removed once the mutating component unmounts or triggers another mutation (since at that point there is no way of getting that data any more.

So if you want something to be "always around", you have to take control of that data and put it somewhere you will find it again and can decide yourself it is going to be removed or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文