Learn React Query In 50 Minutes

Поделиться
HTML-код
  • Опубликовано: 2 июн 2024
  • Learn React Today Course: courses.webdevsimplified.com/...
    TanStack Query (also known as React Query) is my favorite way to interact with an external API. TanStack query is so easy to use and it gives you so many features by default which I love. In this video I go over everything you need to know about TanStack query in order to start implementing it in your React projects.
    📚 Materials/References:
    Learn React Today Course: courses.webdevsimplified.com/...
    GitHub Code: github.com/WebDevSimplified/r...
    What Is React Query Video: • React Query Makes Writ...
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    00:44 - What Is TanStack Query
    01:20 - Setup
    03:18 - Basic Example
    14:15 - useQuery Basics
    26:10 - useMutation Basics
    39:12 - Pagination
    41:28 - Infinite Scrolling
    44:40 - useQueries Hook
    47:22 - Prefetching
    49:13 - Initial/Placeholder Data
    #TanStackQuery #WDS #ReactQuery

Комментарии • 240

  • @be2wa
    @be2wa Год назад +30

    I have not even watched till the end yet, but I can already say that for a react query crash course, this is probably the most comprehensive and useful one I have seen on YT.

  • @ScienceDayYT
    @ScienceDayYT Год назад +11

    I literally was looking for a react query tutorial last night. This is amazing! Thank you!

  • @ashtarpaniagua4732
    @ashtarpaniagua4732 Год назад +32

    This is an incredible crash course. Great job! Also, I'm blown away by how well designed tanstack query seems to be. They seem to have thought of 99% of use cases at first glance. 👏

  • @alanthomasgramont
    @alanthomasgramont Год назад +140

    We replaced all of our reliance on Redux with using react-query in a recent app. The query store is accessible everywhere within the provider, and its easy to requery, update, etc., including manually updating locally when you say add a row so you don't have to pull the whole state down again to get the update. Plus, my favorite part is that data gets stale and goes away, something Redux does not handle. Finally, it has async built in, so you don't need some third-party hack to make async calls and do double actions just to update state. You do the call, state gets updated later, renders happen, everyone is happy.

    • @piyushaggarwal5207
      @piyushaggarwal5207 Год назад +1

      Redux.... Toolkit Query ?

    • @alanthomasgramont
      @alanthomasgramont Год назад +7

      @@piyushaggarwal5207 Redux toolkit is better but react-query is better IMO

    • @Peter-yd2ok
      @Peter-yd2ok Год назад +2

      Does it work well with SSR in Nextjs?

    • @alanthomasgramont
      @alanthomasgramont Год назад

      @@Peter-yd2ok I couldn’t answer that. I’m only starting to learn NextJS right now.

    • @Peter-yd2ok
      @Peter-yd2ok Год назад

      @@alanthomasgramont i see.

  • @rod6722
    @rod6722 Год назад +18

    Right when I needed it. This guy has superpowers!

  • @khoinguyen-ft2ys
    @khoinguyen-ft2ys Год назад +1

    You have everything about calling api + state management just by using React query.
    Thanks Kyle for your very detailed video about React query.

  • @Tyrone-Ward
    @Tyrone-Ward Год назад +4

    Thank you for this. I don’t know why, but your video was way easier to understand than React Query’s documentation.

  • @faithogunlaja4497
    @faithogunlaja4497 Год назад +5

    And by the way, thanks Kyle, you just have ways of reading my mind, you're amazing!! Everything I want to learn you put on the table. I was just thinking of tRPC and almost immediately, I see a notification 😂😂. You're just too good. ♥️

  • @working9990-hafiz-k
    @working9990-hafiz-k 10 месяцев назад +3

    This is a great tutorial. Thank you very much for all the effort you put in.

  • @iJavaScript
    @iJavaScript 10 месяцев назад +5

    That's a great tutorial! I love it!
    It'd be even better if you share your notion notes, so we can reference them as well.

  • @JesseSlomowitz
    @JesseSlomowitz Год назад +7

    So happy to see the React Query crash course; I've learned some new things here even with the months I've implemented it into my projects. It's also great that TanStack has made this type of library for other things like Svelte. Been learning how to implement React Query with Preact Signals to utilize global props and cut down on VDOM to improve React projects. One thing to note is that the obj passed in for the query function has a signal property (an AbortController) which, while excused as not necessary in this video, is essential for any API fetching used to cancel fetch requests if a user changes mid-fetching. This is a great crash course and hoping to see other things like Preact Signals or even Bun talked about soon.

  • @orarbel167
    @orarbel167 Год назад +2

    Great tutorial! Thanks Kyle 🙏🏽

  • @nicholasroman8071
    @nicholasroman8071 2 месяца назад

    Thank you for your tutorials they have benefited me immensely. Right now, I am working on using reactQuery in conjunction with authentication. The samples you have gone over have benefited me a lot especially your presentation on hooks.

  • @johnconnor9787
    @johnconnor9787 10 месяцев назад +8

    24:40 Chaining queries - done with "enabled" property, which is a boolean or an expression that returns boolean
    36:28 The invalidation invalidates all queries starting with a certain key. In order to invalidate the exact query - the second parameter should be used {exact: true}
    37:10 Manually put the data to cache when creating a new, so that it presents even before it is refetched from a backend. Provides better user experience

    • @chrisstucker1813
      @chrisstucker1813 6 месяцев назад +3

      Thanks John Connor. Now get back to fighting skynet

  • @mouhibsahloul2577
    @mouhibsahloul2577 Год назад

    What a great tutorial, I. was planning to learn it for react native and here we go

  • @srinivasnahak3473
    @srinivasnahak3473 8 месяцев назад

    This is the best tutorial by far. I've learned everything I need to know.

  • @2347matte
    @2347matte Год назад +2

    React Query is one of the most consequential additions to the React ecosystem since the beginning. For the first time ever, we can actually separate client state management from server state management and achieve (almost) true separation of concerns. UseQuery and useMutations are kinda like the equivalent of $.get and $.post for JQuery, they allow a service layer to be decoupled from React components. Thus, React being a UI library can be left to what it does best: DOM rendering.

  • @Aaronmoreno
    @Aaronmoreno Год назад

    crazy, I was just looking up resources for react query and this popped up. Perfect timing

  • @yordanov5.0
    @yordanov5.0 4 месяца назад

    Man you deserve a Noble award! Thank you so much!

  • @patrykpuciennik7950
    @patrykpuciennik7950 9 месяцев назад

    I just keep and keep watching you. This is an amazing piece of work you're doing. It really helps various types of devs to leverage the knowledge from your courses / crash courses. Thanks for your hard work I am really amazed by the content quality. Best of luck in the future WDS!

  • @joshuagalit6936
    @joshuagalit6936 Год назад

    I watched it all because I've applied it in my current project 💯💯💯

  • @lexsemenenko7044
    @lexsemenenko7044 Год назад

    This is the perfect example of a technology explanation. The ideal length for its depth.

  • @jpisty
    @jpisty Год назад

    Perfect timing for this tutorial. Thank you thank you thank you!

  • @danielrondongarcia9905
    @danielrondongarcia9905 6 месяцев назад

    Excellent video! As always! thank you for sharing your knowledge.

  • @vasyaqwe2087
    @vasyaqwe2087 Год назад

    Thank you, videos like these are crazy helpful. You're the best!

  • @oliverhughes169
    @oliverhughes169 Год назад

    This is an awesome tutorial, well done and thank you!

  • @developerpranav
    @developerpranav 8 месяцев назад

    🤩 I never build a project without react query anymore. usually with trpc, or with server actions in nextjs!

  • @Sumaila2000
    @Sumaila2000 4 месяца назад

    I love this guy 😁. You make me a better developer and your tutorials are quick and easy to follow.

  • @case6339
    @case6339 10 месяцев назад

    Thanks for this tutorial. It was just the right amount of info with the right length.

  • @TheAzovStar
    @TheAzovStar Год назад

    Very good information. Short, fast and useful.

  • @sachinsainni
    @sachinsainni 4 дня назад

    Kyle, you have a great tutor. and thanks for this show. 🙃

  • @sushieatingcobra
    @sushieatingcobra 7 месяцев назад +1

    amazing thanks for such an incredible crash course

  • @hunterbidenafterlife
    @hunterbidenafterlife Год назад +2

    awesome! please please please please do an in-depth crash course of React-Hook-Form

  • @spencer5051
    @spencer5051 Год назад +3

    RQ is great! I watched your video on xstate from a few days ago and I was thinking how a wrapper around RQ (or a custom hook) would be just as good / better.

  • @JacobDuenke
    @JacobDuenke Год назад

    Hey amazing video as always. This one is a cut above. Thanks Kyle!

  • @luciusartoriusdante
    @luciusartoriusdante Год назад

    I know what I'll be doing this weekend. Thank you!

  • @CreativeB34ST
    @CreativeB34ST 10 месяцев назад +4

    I wish you would have covered the scenario where you have a list of items with different kind of filters like search fields or dropdowns. When a user interacts with a filter and changes its value, it needs to refetch the list with the values of the filters reflected in the fetch request as query parameters. A little bit like the pagination system but more flexible for custom values. That's a common use case and I wonder if React Query has a built-in solution for this. Would love to get your take on this. Great video nevertheless!

  • @user-jn8ws5pq4x
    @user-jn8ws5pq4x Год назад

    Thank you for the tutorial! I've learned a lot.

  • @samandarboymurodov8941
    @samandarboymurodov8941 6 месяцев назад

    Such a useful tutorial. Thank you Kyle a lot!

  • @patrickjreid
    @patrickjreid Год назад

    Love your videos, I would like to suggest that in the future you leave in the lines numbers... it makes taking notes easier.

  • @gmjitendra
    @gmjitendra 3 месяца назад

    Extremely useful. Thank you very much.

  • @geforcesong
    @geforcesong Год назад

    excellent tutorial, thanks Kyle

  • @garudkardnyaneshwar3426
    @garudkardnyaneshwar3426 7 месяцев назад

    Best video ever related to react query ❤❤

  • @hakangundogdu
    @hakangundogdu 6 месяцев назад

    Thank you very much Kyle, I learn a lot from you.

  • @bishalchhetri8817
    @bishalchhetri8817 Год назад

    Wow finally I understand the concept 😍😍

  • @morteza7298
    @morteza7298 10 месяцев назад

    Ty so much for this amazing crash course

  • @amershboul9107
    @amershboul9107 11 месяцев назад

    the most amazing video about react query ✨

  • @arnabchatterjee8556
    @arnabchatterjee8556 Год назад

    I built a whole platform using react query. I didn't have to write a single use effect. It's great actually.

  • @yessay9382
    @yessay9382 11 месяцев назад

    You just save my day! Many thanks

  • @Jaracara11
    @Jaracara11 Год назад

    ReactQuery is awesome! Basically solves all the issues I have with React in a simpler way.

  • @riveto_ir
    @riveto_ir 10 месяцев назад

    Just like a pro! thanks alot!! 🤩😍😇

  • @theouterspace5285
    @theouterspace5285 8 месяцев назад

    Thanks Kyle, this is gold. " Nice ka bai" 😁

  • @nhatduong6595
    @nhatduong6595 Год назад

    Thank you so much for this tutorial

  • @petropzqi
    @petropzqi Год назад +1

    I'm a backend developer. I like to get up to speed on whats happening on the other "side". I must say you did a great job with this video. One of your best so far. Very interesting. Thank you.

  • @HighTechPlus
    @HighTechPlus Год назад +1

    Thank you so much for these tutorials
    Hope you'll make a tuto about Redux toolkit
    Thanks

  • @TechX5others
    @TechX5others Год назад

    thanks a lot. was waiting for you for this

  • @danielChibuogwu
    @danielChibuogwu Год назад

    thanks for this video it was really helpful

  • @pensums
    @pensums Год назад +2

    Thanks for this awesome tutorial,
    I have yet to use it in my personal projects and I'm eager to give it a try. But I have a more or less related question. Is there an advantage of using useRef hooks with the inputs inside a form? Can't you just get the values from the event instead? Basically you already have the inputs data in that event so imo there shouldn't be a reason to create refs for the same inputs data. Also let's say you had 10 inputs in your form, that would be very cumbersome to have 10 refs.

  • @PJ-od9ev
    @PJ-od9ev 6 месяцев назад

    Thanks for the great content. Please teach how to put the data from useInfiniteQuery to a state so we can use it fluently in a react component.

  • @OstonCodeCypher
    @OstonCodeCypher Год назад

    Great tutorial 👌 👍 👏

  • @skgolamsaroar8483
    @skgolamsaroar8483 Месяц назад

    great video.. thank you.

  • @richardmccormack2486
    @richardmccormack2486 10 месяцев назад

    Excellent, succinct content 🤘

  • @vonderklaas
    @vonderklaas Год назад +1

    Kyle, also a suggestion, for enabled option when we fetching users
    For me, this approach -> "enabled: !!postQuery?.data?.userId", worked much better than "!== null" comparision
    Cause, for some reason, React Query still made a request to API, but instead of userId, for a minute there was "undefined", so
    looks like that null check didn't worked for me
    Cheers!

  • @omaracelys3217
    @omaracelys3217 10 месяцев назад

    Bunch of infos, Thank you !
    One advice : try to make a playlist and make it to smaller chunk ,
    i guess you can more views this way and it will be eaiser to use it as reference and come back (also will lead to more views)

  • @meka4996
    @meka4996 7 месяцев назад

    Very good! Thanks!

  • @RizaHariati
    @RizaHariati 10 месяцев назад +1

    Great tutorial. But you must have good solid basic React and fetching to be able to follow this. So fast, you won't get bored. You will get super dizzy, but won't be bored. Thank you! 😂😂😂❤

  • @elwanmayencourt
    @elwanmayencourt Год назад

    I just start using react-query for work this morning, it's fcking amazing

  • @aamirkhan-ql8er
    @aamirkhan-ql8er Год назад

    Hi Kyle, please also make video on react form hook

  • @NZY1990
    @NZY1990 9 месяцев назад

    I can like his videos without watching them. I love you KYLE

  • @davithchhung7577
    @davithchhung7577 Год назад +6

    Redux RTK query does same thing and it's also good combo if we use Redux Toolkit for state management. Otherwise, React Query is perfectly fine to work with any other state management libraries.
    It's also really good to create custom hooks for react-query like usePosts, useCommends, ...etc.

    • @damianszymczuk7796
      @damianszymczuk7796 Год назад +4

      I agree. If your application does not need state, react query looks good. But if you need global state, redux is a better choice.

    • @jsceo
      @jsceo Год назад +2

      @@damianszymczuk7796 zustand is better choice :)

    • @parnasmi
      @parnasmi Год назад +2

      @@jsceo , there is not better choice ever. It depends on the project and your preferences. Though, Zustand is good choice indeed.

    • @himanshujagdale4966
      @himanshujagdale4966 Год назад +2

      @@parnasmi I am new to React, can you please explain why we need state management libraries like zustand and redux if we already have useContext hook?

    • @ItsPureLuck27
      @ItsPureLuck27 Год назад

      @@himanshujagdale4966 I’m wondering this same thing too after just learning useReducer

  • @theisoj
    @theisoj Год назад

    *echo "Great tutorial. Thanks Kyle!"*
    *BTW, when do you make another tutorial about Prisma?*

  • @petrtcoi9398
    @petrtcoi9398 Год назад

    Great video!

  • @Desertphile
    @Desertphile Год назад

    Thank you; I am awed. :-)

  • @darimuhittin
    @darimuhittin Год назад

    Thank you so much.

  • @ernesttan8090
    @ernesttan8090 Год назад

    Thank you Kyle :)

  • @yatorend7890
    @yatorend7890 Год назад

    Awesome!🤩

  • @royhyde8842
    @royhyde8842 2 месяца назад

    Wooooow thanks👏👏👏👏👏

  • @cesarl.c.847
    @cesarl.c.847 Год назад

    Great video. Can share me any link where view use react query library without NPM and load with script CDN. Thanks so much.

  • @ziayamin339
    @ziayamin339 Год назад +1

    Please make a tutorial on how to use react-query with nextjs (SSR)

  • @petarkolev6928
    @petarkolev6928 Год назад

    Kyle, could you do series related to Redux Toolkit && Redux Toolkit Query, please?

  • @leebobtheblob87
    @leebobtheblob87 6 месяцев назад

    8:35 using isLoading and isError before ui rendering logic with successful fetch
    10:30 saving useMutation as variable to use later
    10:54 new entry not being displayed because of cache
    13:11 upon successful mutation -> useQueryClient to invalidate query (with query key)-> re-fetch
    16:07 querykey needs to unique for idnetification
    23:20 changing default staletime ( fetching only happens when data is stale (
    24:59 conditional query : using enabled. Query runs only when specific key exists
    Continue watching from useMutate

  • @abdsha777
    @abdsha777 18 дней назад

    This is 🔥🔥🔥🔥

  • @vickylance
    @vickylance 2 месяца назад

    Can you share with us the notion notes that you took for react query? That would be very helpful

  • @djangodeveloper07
    @djangodeveloper07 Год назад

    i just got your channel and it looks amazing to me. Subscribed Done. can you tell if i want to start react with latest code approach. which videos i need to watch from your channel. i got those videos mixed up.

  • @PM-4564
    @PM-4564 Год назад +1

    For web apps that have files dedicated to business logic that need access to data from the database, RTK query seems more appealing because I assume you could access the query results without a React hook (using Redux-only). Whereas for React Query, it seems like it was designed to only be used inside React components themselves, which doesn't go well with having a business logic files that power your React components,.

    • @DarkzarichV2
      @DarkzarichV2 Год назад +1

      Just want to correct you on that one, you can use your query client outside of react context and then get the data using your queryKey. Just need to export that QueryClient instance
      There is Theo T3 video about state in React and he assures you TanStack Query is all you need for so called server state and for client state you can use something less bloated like maybe jotai is just enough for you and it's much simpler than RTK

    • @parnasmi
      @parnasmi Год назад

      @@DarkzarichV2 Even without react-query using Redux and redux saga I separated the server state and app state into two global states. For server state I used Redux and for app state I used context. Now I am using Next, Prisma, Jotai combination for all that

  • @Joseph-do9ue
    @Joseph-do9ue Год назад

    Thanks

  • @haaris3354
    @haaris3354 9 месяцев назад

    Hi thank you for crash course! Where can i get the Notes you've shown in the beginning of the video

  • @monkeystylle
    @monkeystylle Год назад

    thanks man ..

  • @rael_gc
    @rael_gc 4 месяца назад

    Awesome!

  • @elab4d140
    @elab4d140 Год назад

    Thank you, please do a tailwind tutorial like this

    • @elab4d140
      @elab4d140 Год назад +1

      @@biggestthreattoyourexistence I already know css, but i heard tailwind is much better, but it has different syntax and a learning curve

  • @SLCODEGEN
    @SLCODEGEN 8 месяцев назад

    Thank You!

  • @SuperYoda7
    @SuperYoda7 Год назад

    great video ! I just did not understand how we got the { page } in the querykey in the pagination section. how does this works?

  • @yogeshdatir5983
    @yogeshdatir5983 10 месяцев назад

    What app are you using for note taking? Looks interesting. I use markdown but sometimes I like to have some more features.

  • @arijitpatra
    @arijitpatra Год назад

    thank you. :)

  • @Rothguard98
    @Rothguard98 5 месяцев назад

    Is there a way to get access to those notes? seems like a super helpful resource

  • @tzuilee588
    @tzuilee588 Год назад

    Super handy😁

  • @fabiobaziota5919
    @fabiobaziota5919 Год назад

    Amazing...

  • @abhaykumarsingh3884
    @abhaykumarsingh3884 5 месяцев назад +1

    you should also show us an api that you used for fetching ,without this it is very difficult to understand infinite scroll type stuffs

  • @goldmikanik8274
    @goldmikanik8274 2 месяца назад

    First thank for the amazing free tutorial, I just have a question, I thought when you refresh the page you lose the cached data, but you refreshed it multiple times and the data persisted?
    As of my knowledge the react query library cache data in the javascript runtime environment which reset with refreshing 🤔

  • @graficandorealidades7561
    @graficandorealidades7561 Год назад

    My bro Kyle is reading people's mind at this point