TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

TanStack Query(a.k.a. React Query) v5 announced

62 点作者 milkers超过 1 年前

13 条评论

fabian2k超过 1 年前
There have been endless discussions about state management in React. React Query solved the most common and most annoying part of state management for me, which was everything that you fetched via the network. The part that remains is straightforward enough with the built-in useState&#x2F;useReducer.<p>It does take a moment to learn React Query. You should make sure everyone understands how query keys work and uses them correctly. I saw some confusion there when we started using it, and one developer trying to work around stuff manually that React Query does automatically if you properly set up your query keys and invalidate them.
评论 #37941109 未加载
aj_g超过 1 年前
I would almost consider this a default package to use in a react application for server-side state. Any mildly complex UI will almost immediately need init&#x2F;loading&#x2F;error&#x2F;data states, and you begin to write a wrapper that trends towards what react-query gives you. It makes it a lot easier to by default, write code that provides much better UX. The improvement there far outweighs the small amount of time it takes to learn the library and overhead it introduces.
audessuscest超过 1 年前
I&#x27;ve been using React-query on several projects including the v5 on a recent one. On a new project I decided to give a try to RTK (Redux ToolKit), I must say there&#x27;s not much reason to not use RTK over a lib like react-query. You basically have the same and more, and all the advantages of using react-redux. It felt backward at first to come back to Redux after all this time, but I&#x27;m glad I did, and can&#x27;t recommend it enough. (and the project is still active)
评论 #37941640 未加载
评论 #37941892 未加载
评论 #37941388 未加载
评论 #37941445 未加载
klauserc超过 1 年前
Our team is currently debating whether we should adopt react-query or stick with plain old hand-written code around `fetch`. The team used Apollo in another project, so we are quite familiar with a &quot;heavy handed wrapper&quot; around backend requests. But I&#x27;m not sure the added complexity of react-query is &quot;worth it&quot;.<p>Anyone have experiences to share, either using react-query, a different library or particularly painful memories _not_ using a comparable library?
评论 #37941364 未加载
评论 #37941105 未加载
评论 #37941174 未加载
评论 #37941502 未加载
评论 #37941644 未加载
评论 #37941846 未加载
评论 #37941466 未加载
评论 #37941173 未加载
评论 #37941183 未加载
supermatt超过 1 年前
I currently use SWR. Is there a reason to choose tanstack query over SWR? A cursory look shows them to be near identical in scope, but tanstack is ~3x the bundled size. AFAICS there isnt anything that SWR doesnt support either OOTB or via minor modification to the fetcher (e.g. cancellable requests).
评论 #37941531 未加载
评论 #37941478 未加载
评论 #37941463 未加载
评论 #37941302 未加载
zegl超过 1 年前
Very nice, and well done team!<p>I&#x27;ve been using v5 in production since beta 20, and it has been working very reliable for us since then. The documentation for how to upgrade has been a great resource, and a great example of how to do breaking changes in a library as large as this one.
kebsup超过 1 年前
I&#x27;ve seen multiple projects, in which people try to save results of requests into global state using Redux (not rtk), Zustand etc. and I have never seen it done well. React Query and Redux toolkit really should be the default options for request state management.
phronesis超过 1 年前
&gt; Apart from that, we&#x27;ve renamed cacheTime to gcTime to better reflect what it is doing<p>Does it though? Maybe it&#x27;s super obvious to more experienced users, but now I need to read the docs to find out what &quot;gc&quot; stands for. Not a big deal, just seems like an unnecessary abbreviation, so I&#x27;m curious as to what the reasoning is.
评论 #37941069 未加载
andrewstuart超过 1 年前
My react applications cache nothing and don’t use global state except to put the user Id in localstorage.<p>No redux, no context, no network cache, no nothing.<p>Minimal props.<p>I just use custom events to tell the rest of the application what to.<p>And use fetch to get stuff.<p>Does away with all the complexity of state management or prop drilling.
评论 #37941444 未加载
评论 #37941438 未加载
评论 #37944189 未加载
andy_ppp超过 1 年前
It’s worth noting you can autogenerate TanStack Query clients in a typesafe way using graphql-codegen, really saves a lot of time!
评论 #37943076 未加载
floucky超过 1 年前
I love this package, I&#x27;m able to remove most of my Redux use cases with it.
jrogan993超过 1 年前
Best react package ever.
nsonha超过 1 年前
is there a non react equivalent? I wanna vomit every time I see the word &quot;hook&quot; these days.
评论 #37941658 未加载
评论 #37941496 未加载