An Exciting Update for React Query!

  Рет қаралды 30,451

Josh tried coding

Josh tried coding

10 ай бұрын

React Query has made a super interesting change in their most recent release. You can now stream in data as it's fetched into your UI. That makes for a great UX. Currently, this is experimental - very curious to see how a final version might look. What are your thoughts?
-- my links
Discord: / discord
My GitHub: github.com/joschan21
-- experiment with this change for yourself
tanstack.com/query/v5/docs/re...

Пікірлер: 61
@x1z53
@x1z53 10 ай бұрын
React Query is the most useful library that relieves a huge amount of pain
@TheDeprecatedLibrarian
@TheDeprecatedLibrarian 10 ай бұрын
Can you elaborate pls?
@OryginTech
@OryginTech 10 ай бұрын
Idk, I’m not a fan of writing an axios or fetch req inside every single hook. I like the RTK Querying pattern much more.
@gradientO
@gradientO 10 ай бұрын
Absolutely! Code looks so much cleaner with it (with added bonuses like tracking query status and infinite queries)
@sinkie420
@sinkie420 10 ай бұрын
​@@OryginTechif you're using next I just found out a few days ago that server actions are fully usable on the client now too. I have replace api routes with server actions entirely and use them both on server and on client with react query
@syed.simanta820
@syed.simanta820 8 ай бұрын
Did u ever use React query with Zustand?
@TkDodo
@TkDodo 10 ай бұрын
Thanks for the video 👍. One remark regarding the last graphic: The fetches are not initiated on the client. What happens is that the Query is executed during the SSR pass of the client component (yes, client components are server rendered as well. Confusing, I know), so the fetches happen _on the server_. Then, the results are streamed to the client, where they are put into the QueryCache, just as if you'd manually dehydrated them in the "old getServerSideProps".
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
I thought about this a lot. This makes perfect sense. I was really confused as to why the fetches still show up in the network tab, though? Thanks for explaining! (edit) Exactly! So this was precisely what I thought happened. I even draw a complete diagram for this process but got really thrown off by the query still showing up in the network tab.
@ayushjain7023
@ayushjain7023 10 ай бұрын
So, in short with this new experimental package, you do not need to manually handle hydration or pass the initial data as a prop from a server component to a client component. When the initial request is made, the data will be fetched on the server, which means the API request from the useQuery hook is first initialized on the server to fetch the data. Once the data is ready, it will be automatically made available in the QueryClient on the client.
@mathiasriissorensen6994
@mathiasriissorensen6994 3 ай бұрын
Okay, so you are saying the prefetch and HydrationBoundries are no longer needed?
@lucasfranzolin
@lucasfranzolin 10 ай бұрын
I can tell I am already a big fan of you!! Thanks again for the updates
@helleye311
@helleye311 10 ай бұрын
Amazing! I was hoping to see some nicer react query API for SSR and server components in general, seems like this will be it. Just need to wait for it to stabilize and I'll be happy to move to app router for my projects.
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
Same, this is a really nice step in adopting the app router
@tunaralyarzada
@tunaralyarzada 10 ай бұрын
That was great update Josh! But, i would like to ask you kinda different question. Do you know the example website with src code that has flexible and maintanable configuration for best reusable ui components of MUI library in react app?
@GabrielMartinez-ez9ue
@GabrielMartinez-ez9ue 9 ай бұрын
Hi josh. Is it possible for you to make a video tutorial of the prefered way of using nextjs 13 server components with react query? How would you do it?
@perrythepalteypus2185
@perrythepalteypus2185 10 ай бұрын
Not Many tutorials on react query please make a full tutorial it would be helpful 😊
@mohithguptakorangi1766
@mohithguptakorangi1766 10 ай бұрын
that was complex as someone who has not user react-query, can there be a tut on this part but as a longer video?
@ankushagarwal7378
@ankushagarwal7378 10 ай бұрын
Hey bro love your videos every time I learn something new on your channel but can you tell me what gzipped next to your code when you import something and how I do it too ?
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
it's called import cost, it's a VSCode extension
@swdotdev
@swdotdev 10 ай бұрын
Is there a reason why you return an array instead of an object from useWaitQuery?
@marknovak1430
@marknovak1430 10 ай бұрын
Random question. Does anyone know which VS theme Josh uses? Thanks!
@ilyazinkevych7804
@ilyazinkevych7804 10 ай бұрын
I didn't get what is streamed here and the difference between previous "no suspense: true"? didn't you just use suspense and showing fallback loaders while response delayed as usual...
@ilijanl
@ilijanl 10 ай бұрын
Me neither lol
@yozhis1
@yozhis1 10 ай бұрын
guy totally missed the whole point of this new feature. just showing loader like with isLoading or isFetching.
@julianklumpers
@julianklumpers 10 ай бұрын
It also worth mentioning: BlitzJS. i believe they also use react-query under the hood and it also supports suspense.
@emee__
@emee__ 10 ай бұрын
Bro the way you say Beautiful, or Intuitive hypes me up 🚀🚀🚀
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
hahaha cheers man
@saralightbourne
@saralightbourne 10 ай бұрын
could anyone advise how to trigger loading.tsx when url query parameters change? when i useRouter and change url query parameters, it does run page.tsx and gets new data from it but loading.tsx isn't shown so the page is just stuck for some time. loading.tsx is shown only when the page is initially opened. with next.js pages, i could use shallow: true and handle all that logic on the client side with initial data passed as props but with app router i have no idea how to solve this pretty common case
@nwaformicah433
@nwaformicah433 10 ай бұрын
Thanks big man, can you make a full tutorial on react query that covers infinite scroll?
@animegeek-011
@animegeek-011 10 ай бұрын
What's the difference between this method and fetchStatus or isLoading state for loading spinner ?
@hernan4485
@hernan4485 10 ай бұрын
It's affect mostly next and ssr. On a client you would use this to render one component or another. With Suspense you can just have a loading fallback and anytime any component from below is fetching and using that suspense will be triggered. Just another way to make easier fetching instead of having in all the components that you fetch the same if (isLoading) if (isError) etc logic. Can be wrong tho
@RegalWK
@RegalWK 10 ай бұрын
In React, both useEffect and Suspense can be used for data fetching, but they have quite different ways of handling it. useEffect is more imperative, whereas Suspense is more declarative. useEffect is a Hook in React that lets you perform side effects in function components. A common use case for useEffect is to fetch data when a component mounts. Suspense is a more declarative way to handle data fetching in React. Suspense allows you to specify a loading state while waiting for some asynchronous operation to finish, like data fetching. To use Suspense for data fetching, you would generally use it in combination with React's concurrent mode and a data fetching library that integrates with Suspense
@mamunahmed8113
@mamunahmed8113 10 ай бұрын
How may I fetch on server side by react query?
@buddy.abc123
@buddy.abc123 10 ай бұрын
"in the past...you would use a suspense component" Dude that's the present 😅
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
well fair point
@buddy.abc123
@buddy.abc123 10 ай бұрын
@@joshtriedcoding time flies in the js ecosystem
@jmula1963
@jmula1963 10 ай бұрын
how is this better than suspense
@michakrecisz5100
@michakrecisz5100 10 ай бұрын
How streams affect SEO, both RQ and RSC... also how that affect servers in terms of performance.
@rockNbrain
@rockNbrain 10 ай бұрын
Tan is a real rockstar!
@Rasty_Boss
@Rasty_Boss 10 ай бұрын
Great news, can it be in production already?)
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
it's just experimental, wouldn't do that
@alvinscheibe
@alvinscheibe 10 ай бұрын
Awesome! 👏👏👏
@dexteralanbalderama3746
@dexteralanbalderama3746 9 ай бұрын
why cant i call a use query inside a function??
@aBradAbroad
@aBradAbroad 10 ай бұрын
Amazing
@umargulzar2982
@umargulzar2982 10 ай бұрын
You are Guru of react.😅😅
@Tommy-x-Ray
@Tommy-x-Ray 7 ай бұрын
I don't see the difference between this and just using 'isLoading' and then conditional rendering ... ??
@faridguzman91
@faridguzman91 10 ай бұрын
TanStack is king
@anhdunghisinh
@anhdunghisinh 10 ай бұрын
will this help trpc, too?
@lukemoralesTV
@lukemoralesTV 10 ай бұрын
This was actually made by the tRPC maintainers
@mohitcodeswell
@mohitcodeswell 10 ай бұрын
Heyyy josh! No giveaway this time ? LOL 😂
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
It's weird the spam filters catch on to those telegram scam comments and automatically delete them, yet still allow them to be posted
@Tommy-x-Ray
@Tommy-x-Ray 10 ай бұрын
lmao
@NatnaelAbebe-og8bt
@NatnaelAbebe-og8bt 10 ай бұрын
if start coding, web development or full stack dev today is it an opportunity to get a job remotely
@notkamui9749
@notkamui9749 10 ай бұрын
meanwhile Nuxt: useLazyFetch
@riolly
@riolly 10 ай бұрын
I don't get it honestly
@puopg
@puopg 10 ай бұрын
All this stuff has already been done in react-relay for years now lol
@lapulapucityrider3227
@lapulapucityrider3227 10 ай бұрын
This already exist way before
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
nope, just got released a couple days ago in a 5.0 experimental alpha version
@lapulapucityrider3227
@lapulapucityrider3227 10 ай бұрын
@@joshtriedcoding you are right the react query next but suspense true config already exist way before
4 UI Design Tools I Can't Live Without
5:08
Josh tried coding
Рет қаралды 65 М.
Chips evolution !! 😔😔
00:23
Tibo InShape
Рет қаралды 40 МЛН
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 9 МЛН
Bro be careful where you drop the ball  #learnfromkhaby  #comedy
00:19
Khaby. Lame
Рет қаралды 36 МЛН
how to sign up in Canva pro for free 2025
3:38
ذويب محمد - douib mohammed
Рет қаралды 22
What's New in React Query 5.0?
5:26
Josh tried coding
Рет қаралды 55 М.
Why I don't use React-Query and tRPC in Next.js
18:58
ByteGrad
Рет қаралды 68 М.
Next 14 + React Query COMBO with Server Actions and RSC
9:49
developedbyed
Рет қаралды 84 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 146 М.
Why I avoid useEffect For API Calls and use React Query instead
17:45
How Did I Not Know This TypeScript Trick Earlier??!
9:11
Josh tried coding
Рет қаралды 200 М.
We Need to Talk About Redis.
14:55
Josh tried coding
Рет қаралды 87 М.
I Made This Open-Source Project
7:22
Josh tried coding
Рет қаралды 67 М.
wyłącznik
0:50
Panele Fotowoltaiczne
Рет қаралды 20 МЛН
Samsung Android Mobile Battrey
0:39
Gaming zone
Рет қаралды 342 М.
Very Best And Good Price Smart Phone
0:42
SDC Editing Zone 9K
Рет қаралды 217 М.