An Exciting Update for React Query!

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

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 10 ай бұрын
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?
@emee__
@emee__ 10 ай бұрын
Bro the way you say Beautiful, or Intuitive hypes me up 🚀🚀🚀
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
hahaha cheers man
@perrythepalteypus2185
@perrythepalteypus2185 10 ай бұрын
Not Many tutorials on react query please make a full tutorial it would be helpful 😊
@marknovak1430
@marknovak1430 10 ай бұрын
Random question. Does anyone know which VS theme Josh uses? Thanks!
@swdotdev
@swdotdev 10 ай бұрын
Is there a reason why you return an array instead of an object from useWaitQuery?
@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
@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
@mamunahmed8113
@mamunahmed8113 10 ай бұрын
How may I fetch on server side by react query?
@julianklumpers
@julianklumpers 10 ай бұрын
It also worth mentioning: BlitzJS. i believe they also use react-query under the hood and it also supports suspense.
@nwaformicah433
@nwaformicah433 10 ай бұрын
Thanks big man, can you make a full tutorial on react query that covers infinite scroll?
@rockNbrain
@rockNbrain 10 ай бұрын
Tan is a real rockstar!
@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
@alvinscheibe
@alvinscheibe 10 ай бұрын
Awesome! 👏👏👏
@aBradAbroad
@aBradAbroad 10 ай бұрын
Amazing
@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
@umargulzar2982
@umargulzar2982 10 ай бұрын
You are Guru of react.😅😅
@michakrecisz5100
@michakrecisz5100 10 ай бұрын
How streams affect SEO, both RQ and RSC... also how that affect servers in terms of performance.
@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.
@dexteralanbalderama3746
@dexteralanbalderama3746 9 ай бұрын
why cant i call a use query inside a function??
@Rasty_Boss
@Rasty_Boss 10 ай бұрын
Great news, can it be in production already?)
@joshtriedcoding
@joshtriedcoding 10 ай бұрын
it's just experimental, wouldn't do that
@faridguzman91
@faridguzman91 10 ай бұрын
TanStack is king
@Tommy-x-Ray
@Tommy-x-Ray 7 ай бұрын
I don't see the difference between this and just using 'isLoading' and then conditional rendering ... ??
@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
@riolly
@riolly 10 ай бұрын
I don't get it honestly
@notkamui9749
@notkamui9749 10 ай бұрын
meanwhile Nuxt: useLazyFetch
@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
What's New in React Query 5.0?
5:26
Josh tried coding
Рет қаралды 55 М.
A Better Way to Write APIs?
12:00
Josh tried coding
Рет қаралды 85 М.
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 25 МЛН
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 48 МЛН
Pokey pokey 🤣🥰❤️ #demariki
00:26
Demariki
Рет қаралды 4,2 МЛН
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 3,3 МЛН
Next 14 + React Query COMBO with Server Actions and RSC
9:49
developedbyed
Рет қаралды 84 М.
How Did I Not Know This TypeScript Trick Earlier??!
9:11
Josh tried coding
Рет қаралды 201 М.
React-query Cache in Local Storage with persistQueryClient
1:25
The Problem With UUIDs
6:36
Josh tried coding
Рет қаралды 66 М.
Oh, Auth Doesn't Have to Suck?
7:16
Josh tried coding
Рет қаралды 51 М.
This is TypeScript's Most Powerful Keyword
4:22
Josh tried coding
Рет қаралды 11 М.
Fetching Data Doesn't Get Better Than This
6:58
Josh tried coding
Рет қаралды 58 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 448 М.
Creating High-Quality React Components: Best Practices for Reusability
12:47
The power button can never be pressed!!
0:57
Maker Y
Рет қаралды 53 МЛН
Эволюция телефонов!
0:30
ТРЕНДИ ШОРТС
Рет қаралды 6 МЛН
Very Best And Good Price Smart Phone
0:42
SDC Editing Zone 9K
Рет қаралды 217 М.
Apple watch hidden camera
0:34
_vector_
Рет қаралды 49 МЛН
A Comprehensive Guide to Using Zoyya Tools for Photo Editing
0:50