React Query Tutorial for Beginners vs Redux, Axios with CRUD Example

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

ความคิดเห็น • 180

  • @hamzahahmad1670
    @hamzahahmad1670 2 ปีที่แล้ว +32

    Absolutely underrated gem of a channel. This was such a brief yet thorough

  • @VernonSwanepoel
    @VernonSwanepoel 2 ปีที่แล้ว +4

    Brilliant. I've been on a project at work, in a fairly large codebase using react query already, and I'm still learning react itself, so there has been a lot to get my head around. This helped me a lot!

  • @eazye7059
    @eazye7059 2 ปีที่แล้ว +3

    Much simpler than RTK Query! Thanks

  • @raffaelenicosia9335
    @raffaelenicosia9335 2 ปีที่แล้ว +1

    Dave, you're definetly raising the bar!

  • @abuhossain4274
    @abuhossain4274 ปีที่แล้ว

    as your lesson its clear that rtk and react query use case depends on the size of project.

  • @oortcloud210
    @oortcloud210 ปีที่แล้ว +1

    What a fantastic video. Everything explained so concisely and clearly. Thank you!

  • @ramusubbu3778
    @ramusubbu3778 2 ปีที่แล้ว +2

    Videos like this will be interesting!! Concentrating on one task! And explaining different methods by which we can achieve the task!

  • @ms77grz
    @ms77grz 2 ปีที่แล้ว

    Thx! I use RQ and Recoil at the moment.

  • @mrbilchalan
    @mrbilchalan 2 ปีที่แล้ว +2

    Hello Dave, I have watched almost all of your video tutorials. If you have some time, I am expecting a socket io And a sequalize tutorial from you. Please carry on. Thank you.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +3

      You're welcome and thank you for the requests! 🙏💯

  • @thecutedreamkostasp.4449
    @thecutedreamkostasp.4449 2 ปีที่แล้ว +1

    Another excellent tutorial! You sir and net ninja are the best out there!! Ty!!!!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Wow, thanks! 🙏 You have put me in great company, and I sincerely appreciate the kind words!! 💯

  • @frankli7035
    @frankli7035 2 ปีที่แล้ว +1

    really love all your videos,just one request could you please write in typescript rather than JS……that will be more helpful

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +3

      I do plan to do a TypeScript series this year. I'm for beginners first, and they need to learn before moving to TS, too. You'll see both with and without here in the future 💯

    • @frankli7035
      @frankli7035 2 ปีที่แล้ว

      @@DaveGrayTeachesCode that's amazing,that's for your time

  • @vladyslavdremliuha6147
    @vladyslavdremliuha6147 7 หลายเดือนก่อน

    Hi, Dave! Your video is super existing to watch and teach myself a little bit but my sort function is now working (todo items go to the very bottom of list). Don't have any clue why it is working that way.. Even despite taking and pasting your code from the git hub source.

  • @MrQVeeBoo
    @MrQVeeBoo ปีที่แล้ว

    thx. straight to the point and this one is very easy to understand.

  • @minijavi19
    @minijavi19 ปีที่แล้ว

    Great work! Loved your video.
    Just one thing I'm not quite understanding... where are we mapping our ./data/db.json to the Todo api? how does the app knows?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      Going by memory here - If I used json-server as a dev database, when you launch json-server, it tells you the address and port number it is available on.

  • @manoj03h
    @manoj03h ปีที่แล้ว

    I too like RTK Query with Redux

  • @surajjha5623
    @surajjha5623 2 ปีที่แล้ว +11

    Just curious, is there any to-do for making videos about nextjs in your to-do list.😅

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +9

      😂 later this year is the plan. MERN and Typescript had more votes and will come first 🚀

    • @codernerd7076
      @codernerd7076 2 ปีที่แล้ว

      @@DaveGrayTeachesCode you can do MERN with Next.js...

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +3

      @@codernerd7076 yes, but I always like to provide a foundational tutorial series first. That lets me refer back to it when answering questions.

    • @codernerd7076
      @codernerd7076 2 ปีที่แล้ว +1

      @@DaveGrayTeachesCode It will work for the best same, As you may know, Next.js will make some major changes in their routing/layout system according to their latest blog posts, so the tutorials would be kinda outdated with the new version finally comes out. 😀

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      @@codernerd7076 Right! Technology keeps moving 🚀

  • @AnnieTaylorChen
    @AnnieTaylorChen 2 ปีที่แล้ว +2

    I was going to ask you the "fetch" vs. "axios", is it still relevant today to use "axios"? I saw you are using it in React tutorial.
    Lately I've been considering React Query and will definitely check out this video too!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Yes, you can use Axios. You can even use Axios with React Query! I hope the video helps!

  • @Pareshbpatel
    @Pareshbpatel 2 ปีที่แล้ว

    Excellent Tutorial on React-Query. Thanks, Dave
    {2022-10-13}, {2022-11-10}, {2022-11-17}

  • @MarlonEnglemam
    @MarlonEnglemam 6 หลายเดือนก่อน

    Do you think it’s ok to use react query to fetch data from the backend services and at the same time use redux toolkit to persiste some info that comes from those requests?! Let’s say I want to save user info so that it can be seen from different screens. I’m not sure about how to go with that, it feels “wrong”, at the same time I don’t like RTK Query very much since it’s more opinionated

  • @mhdfirassbarakat6587
    @mhdfirassbarakat6587 ปีที่แล้ว

    "let me know what you like in the comments" well ...... I like your videos so please for the humanity future keep going making this great content

  • @mohammadawais1566
    @mohammadawais1566 2 ปีที่แล้ว +2

    Dave your way of teaching is just awesome♥️
    You and john smilga are best instructors for web development

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Thank you for the kind words, Mohammad! 🙏 It's an honor to be mentioned with John 💯

  • @shnam928
    @shnam928 2 ปีที่แล้ว

    Thanks a lot. Can we use useQuery for GET and for post, put and delete we use useMutation?

  • @sinhuu.s2
    @sinhuu.s2 2 ปีที่แล้ว

    congratulations !! very good. so that I use an add function on another page, for example, just import TodoList and use the addTodoMutation function?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      TodoList is a component in this video. If using addTodoMutation, you also need to import the addTodo function.

  • @daniel_narh
    @daniel_narh ปีที่แล้ว

    Please what programming font are you using? The one in this video seems pretty decent. Taking this as a crash course

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      I show my font choices in this short: th-cam.com/users/shortsf1HVI5slxms

  • @farhanizzaz5283
    @farhanizzaz5283 2 ปีที่แล้ว

    hello, may i know why u used the select meanwhile the docs said that the third parameter is for the cache time? thank you

  • @cortex3657
    @cortex3657 ปีที่แล้ว

    While mutating does all todos re render?????

  • @fares.abuali
    @fares.abuali 2 ปีที่แล้ว +1

    Thanks! Mr. Dave

  • @laxmiprasanna4092
    @laxmiprasanna4092 ปีที่แล้ว

    Does components render or update if server state changes in React query ? I mean without maintaining additional client state.

  • @Un0Real333
    @Un0Real333 2 ปีที่แล้ว

    What is your opinion on using Redux and Axios (instead of RTK) for a big project? I just love using axios.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      You can use Axios with Async Thunks. I show that in my Redux course before moving on to RTK Query. That said, you can also use Axios with RTK Query although I did not demonstrate it. You can implement it as shown in the docs here: redux-toolkit.js.org/rtk-query/usage/customizing-queries#axios-basequery

  • @AmirulIslam-uj3yz
    @AmirulIslam-uj3yz ปีที่แล้ว

    Thank you Mr Dave

  • @mdameer0732
    @mdameer0732 ปีที่แล้ว

    so the content variable was not a state variable and yet the changes were reflected like it was a state variable? how

  • @jordanryanethanowona2974
    @jordanryanethanowona2974 ปีที่แล้ว

    I absolutely love your channel. Of course i just subscribed lol. I have a question please. Do you have a video with Reactquery with jwt refresh tokens? and rbacs? basically with the middleware ? thanx a lot for everything. you are the real MVP lol.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      Thank you! No I do not currently. You could take what is in my React Auth playlist and apply it with React Query though. I should cover this with RQ in the future.

    • @jordanryanethanowona2974
      @jordanryanethanowona2974 ปีที่แล้ว

      @@DaveGrayTeachesCode Thanx a lot

  • @josephtan6018
    @josephtan6018 2 ปีที่แล้ว +1

    Hi Dave. Thank you for this video. So you prefer redux and rtk query. Is it redux toolkit and rtk query? If so, do you have a repo project for that? Thank you!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Based on project size and needs, I would choose. I do have a full modern Redux course with Redux Toolkit and RTK Query: th-cam.com/video/NqzdVN2tyvQ/w-d-xo.html

    • @proletar3799
      @proletar3799 2 ปีที่แล้ว

      in this video, he was showed to us to use react-query and react-query is different package with rtk query..rtk-query is addon with in rtk package. im prefer to use rtk-query instead of react-query. for me it seems a bit similiar with react-query.
      repo rtk-query: shorturl.at/jsvG7

  • @AkshayKumar-kz6zh
    @AkshayKumar-kz6zh 2 ปีที่แล้ว +1

    I was going through the documentation and sir you dropped a video. Thank you very much for such great tutorials! Also 69th like. Nice

  • @saurabhpathak6177
    @saurabhpathak6177 2 ปีที่แล้ว

    I am getting an network error with checkbox element and it is not getting checked on unchecked.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      You can compare to my source code to find the difference.

  • @Reebak018
    @Reebak018 ปีที่แล้ว

    Thanks for this video.
    Also is this the same as TanStack Query ?; as far i know should be the same, the only difference is TanStack is avaiable for other frameworks.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      Yes, it was previously called React Query. The overall concept is the same but there may have been a few updates since I made this video.

  • @Abbos_700
    @Abbos_700 8 หลายเดือนก่อน

    Thank you very much for your lessons Dave. You are helping lots of people around the world. Could you please update this course to tanstackQuery v5

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  8 หลายเดือนก่อน

      Great request! I need to do this.

    • @Abbos_700
      @Abbos_700 8 หลายเดือนก่อน

      @@DaveGrayTeachesCode Great tysm, then I look forward to it.

  • @kishoreandra
    @kishoreandra 2 ปีที่แล้ว

    super helpful video yet again Dave ... 💯

  • @dharmeshgohil9375
    @dharmeshgohil9375 2 ปีที่แล้ว

    i have question for can you tell something when will MERN project will come ? and which type of that project like ecommerce or blog website ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      MERN project later this summer. Not a blog but something based on examples where I can highlight what is needed.

  • @portiseremacunix
    @portiseremacunix 2 ปีที่แล้ว

    thanks for the tutorial again! do you have any plans for projects?

  • @IzharJumadi
    @IzharJumadi ปีที่แล้ว

    Great stuff! Thanks so much for sharing :)

  • @benarbiamohamedtaher546
    @benarbiamohamedtaher546 2 ปีที่แล้ว

    Excellent tutorial,thank you gray

  • @sonamohialdin3376
    @sonamohialdin3376 2 ปีที่แล้ว

    Awesome tutorial thank you, regarding your question, i prefer React Query more than Redux RTK Query

  • @sherinc7998
    @sherinc7998 ปีที่แล้ว

    Is it possible to use react query in project redux toolkit is used for state managmemt ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      You mean instead of Redux Toolkit? Yes. If you mean at the same time - I don't think I would use them together.

  • @brayandvelasquez2256
    @brayandvelasquez2256 2 ปีที่แล้ว

    Great video! quick question, how React Query says, do u even use Redux anymore?
    Watching this video I can say it is better and more clean code than using Redux, Thunks and things like that. What do u think? I just started a big Proyect and we decided to use React Query for all our work, but that, more understanding using React Query than others libraries

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      React Query is a great choice for many projects! I like it! 💯

  • @JagdishChoudhary
    @JagdishChoudhary ปีที่แล้ว

    In one of the large-scale projects, I am planning to use Redux-Toolkit for "client state" management, as I have so many modules and features such as Search, Advance Filter, infinite scrolling etc. So that I can store the state in the Redux toolkit using store and slices. Now I love React-Query because of "useInfiniteQuery", but I don't want to increase the bundle size as well by installing another library.
    One of the use case: When I get the list of data from the server, I want to cache the data, and if the user search or filter the data, I want to store the "searchText" and "FilterData" in the state, so when user navigate between pages and come back to the listing page, I can simply provide the already filtered data, that will sure improve the UX.
    So is it a good idea to stick with RTK Query as it is available inside the Redux-toolkit package and be in the same eco-system?

    • @chrisstucker1813
      @chrisstucker1813 ปีที่แล้ว +1

      If you're using Redux Toolkit I would probably just stick with RTK Query since it is built on top of Redux Toolkit and Redux Toolkit is built on top of Redux. It's like an all-in-one package to take care of both server and client side state. Plus you can pass in your RTK query reducers into your general Redux store along with the reducers for your client side stuff. So you can create one Redux store to hold both of your client and server side states.
      A more lightweight solution could be Zustand for client side state and React Query for server side state. It tends to keep things more simple and less convoluted than Redux.

    • @JagdishChoudhary
      @JagdishChoudhary ปีที่แล้ว

      @@chrisstucker1813 Thanks for the response.
      Staying in the ecosystem would make more sense.

  • @mohammadmahdialvansaz8001
    @mohammadmahdialvansaz8001 ปีที่แล้ว

    Thank you.

  • @howiewang4238
    @howiewang4238 ปีที่แล้ว

    Thank you for making this tutorial.

  • @ashharkausar413
    @ashharkausar413 2 ปีที่แล้ว

    In your opinion what is best for a react store? An example is a store containing the following: JWT access token, refresh token, name, credit card token etc. I have feeling you will say RTK but do you think RQ is good also?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Good question - and definitely just an opinion as there is no right or wrong here. Whatever you like and are most comfortable with will work. Redux & RTK Query are usually for more enterprise (large) apps. I would reach for React Query or similar in most small to medium projects, but there are some considerations. React Query works with caches. If you need some local state in addition, you could use the built-in Context API whereas RTK Query can just use Redux for state.

    • @ashharkausar413
      @ashharkausar413 2 ปีที่แล้ว

      @@DaveGrayTeachesCode cool ty

  • @jatilyadav4000
    @jatilyadav4000 ปีที่แล้ว

    Amazing video as always

  • @brayandvelasquez2256
    @brayandvelasquez2256 2 ปีที่แล้ว

    I dont understand why when I am using React Query in Observers I get 26 or 29 in it. You can say why?

  • @anshvashisht8519
    @anshvashisht8519 ปีที่แล้ว

    22:23 for update todo logic

  • @abdomahmoud8769
    @abdomahmoud8769 2 ปีที่แล้ว +1

    Hi Dave!
    Can you make an accessibility course so our websites become more useable.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Thanks for asking! This is an item on my ToDo list! It is something I definitely want to create. 🚀

  • @TradingBloke
    @TradingBloke 9 หลายเดือนก่อน

    do you think for the job of junior react developer react query is needed?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  9 หลายเดือนก่อน

      It is good to know. Specifically it will depend on the job.

  • @alexshepel9387
    @alexshepel9387 2 ปีที่แล้ว

    Awesome tutorial, thx!

  • @MusicMan121
    @MusicMan121 ปีที่แล้ว

    9:50 I did this like this at work and I was called out because they say you're not supposed to have so many similar CRUD methods.

  • @shakhawathhossainshatu1487
    @shakhawathhossainshatu1487 ปีที่แล้ว

    Thank you so much for videos

  • @handikadwi7559
    @handikadwi7559 ปีที่แล้ว

    Would you update this course to use React Query v4?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      I can do another video. I cannot update a video that is already published. Overall, this intro tutorial just covers the basics, and I don't think much has changed for these.

  • @elinordeniz
    @elinordeniz ปีที่แล้ว

    Hi Dave,
    We would like intermediate to advanced react or mern stack projects. That would be so useful for us after all these great tutorials. Thank you for all.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      You're welcome! Have you tried my MERN Stack Course? It's a big project: th-cam.com/video/CvCiNeLnZ00/w-d-xo.html

  • @Rafiki041087
    @Rafiki041087 ปีที่แล้ว

    Really good content, I'm new to react and these videos are a great way to learn.

  • @permanar_
    @permanar_ 2 ปีที่แล้ว

    freaking awesome dude.
    cool!
    could you do another video with swr maybe with React/Next.js by any chance tho?
    really appreciate this hard work anyway 🎉🎉

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Looking forward to covering Next.js later this year! 🚀

  • @햄버거맨-g8c
    @햄버거맨-g8c 2 ปีที่แล้ว

    Thanks for your tutorial.

  • @abhishekbohora9691
    @abhishekbohora9691 2 ปีที่แล้ว

    Why the github repository linked below doesn't have any dependency in package.json in both intro and starter.. there is only css code..?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      The starter code does not have the dependencies because I walk you through adding them in the tutorial. However, if you look at the completed project, all of the dependencies are already listed in the package.json. Clone the repository and then run npm update to install all of the dependencies.

  • @ssj1260
    @ssj1260 2 ปีที่แล้ว

    Thanks for the video, great intro to react-query.
    Quick question if you don't mind. Why do you use a variable with JSX instead of a Component? (e.g. newItemSection), is there any benefits to this or is it personal preference?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Good question! It is something I started doing awhile back. I like defining everything including what I am going to return, but there is no requirement to do so.

  • @jniyaz
    @jniyaz 2 ปีที่แล้ว

    on rtk query vs react query.. seems react query is much simpler to implement.. since rtk query is supported by the same redux team.. hav some advantage.. What do you think Dave?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Yes, I do agree that React Query is an easier implementation. If you do not have a large project - specifically if you do not need global state management - React Query is a good choice. RTK Query integrates with Redux and is great when you do need global state management.

    • @jniyaz
      @jniyaz 2 ปีที่แล้ว

      fully agree.. ✌

  • @hungnguyencanh5089
    @hungnguyencanh5089 2 ปีที่แล้ว

    Thank you so much!

  • @jaikrishna3586
    @jaikrishna3586 ปีที่แล้ว

    I learned a lot today.

  • @henriqueomena7686
    @henriqueomena7686 2 ปีที่แล้ว

    you do amazing videos, but plz could you do then with typescript ? would be amazing if you can do it, the market almost always expect for typescript

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you, Henrique! 🙏 I want to provide both. I will make a TypeScript tutorial series that will allow me to refer beginners back to it when I do other tutorials with TS. I always want to keep things beginner friendly along the way. 🚀

  • @annusingh4694
    @annusingh4694 2 ปีที่แล้ว +3

    Hi Dave, I absolutely love your tutorials. Can we know if you'll be making any fullstack (Typescript) tutorials as well ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +9

      Eventually, yes. I want to do a TypeScript series first. That will allow me to refer beginners back to it for fundamentals & questions. 🚀

  • @dharmeshgohil9375
    @dharmeshgohil9375 2 ปีที่แล้ว +1

    awesome tutorial

  • @rakhisingh9797
    @rakhisingh9797 2 ปีที่แล้ว

    Bro if you have one choice which one you choose rtk query or react query?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      Hi Rakhi, as I mentioned in the video, it is really situational but I lean towards RTK Query. Redux is a marketable skill that could help with jobs and RTK Query is part of modern Redux. 🚀

  • @hypermeero4782
    @hypermeero4782 2 ปีที่แล้ว

    man you're just so amazing

  • @gunasekarant6498
    @gunasekarant6498 2 ปีที่แล้ว

    Awesome one 🙂

  • @viktorkasap
    @viktorkasap ปีที่แล้ว

    Дэйв, спасибо, отличный обзор библиотеки
    Но хотелось бы увидеть весь потенциал, напримере какого нибудь список дел,
    чтобы можно было отметить готово дело или нет, с отдельной страницей каждого дела, с пагинацией и чтобы не было перерендеров (наверное это ключевое) =)

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      Thank you! Yes, you could go deeper here. Create a component for each Todo and use React.memo on those components to prevent unnecessary re-renders.

    • @viktorkasap
      @viktorkasap ปีที่แล้ว

      ​@@DaveGrayTeachesCode React.memo - Is there only one way to solve this problem?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      @@viktorkasap no but it's usually the solution I prefer.

    • @viktorkasap
      @viktorkasap ปีที่แล้ว

      ​@@DaveGrayTeachesCode Thank you very much 🙏

  • @shubhammishra1136
    @shubhammishra1136 2 ปีที่แล้ว +1

    Nice video. One question though... What do you think of redux-saga for doing asynchronous task. I have seen that it still has over a million downloads on npm. So, what would be good of big projects ? Is it saga or rtk-query?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      Great question! I should do a comparison 💯 After completing my Redux series, I wanted to do a few other topics, but I'll get back to it. 🚀

    • @none0n
      @none0n ปีที่แล้ว

      @@DaveGrayTeachesCode is this out?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      @@none0n I did not do this yet. So many topics to cover! 😀My channel is searchable from the channel homepage.

    • @none0n
      @none0n ปีที่แล้ว

      @@DaveGrayTeachesCode fingers crossed. I’m trying to design a Frontend style that’s reusable. This video helped me understand react query

  • @thattablebloke
    @thattablebloke 2 ปีที่แล้ว

    Hey Dave, another great vid, thank you. I'm using React Query for a project and have the basic fetching and mutations going - one thing I'm wondering if it's possible to do is when a component/page loads, check react-query data I have in cache already from other pages for a matching id to save having to fetch this item again. If it's there, just use that data. If not, fetch the data. Is this possible, or way too much to be doing? I've been trying to figure out for ages now but can't quite figure it out..

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      React Query accepts a function where you can select the data you need. Let's say you query users data for a users list and then go to an individual users page. You can pass a select function into the same query on the individual user page. It should used the cached data instead of making a new request - unless the cache has expired. You can control this expiry with more detail by following the example under "Conditional Initial Data from Cache" here: tanstack.com/query/v4/docs/guides/initial-query-data

    • @thattablebloke
      @thattablebloke 2 ปีที่แล้ว

      @@DaveGrayTeachesCode Thanks, I'll dig into this! My possible issue is having a separate cache for the individual items and then all items. I'd like to check [all-items] cache for an id that matches one passed as a param to the indiv item page, if there, populate the [indiv-item] cache with this data (but if the cache doesn't exist yet.. ??) A lot to figure out, but I'll start with that link and hopefully can get there.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      @@thattablebloke look at "select-partial-subscriptions" : tkdodo.eu/blog/react-query-data-transformations

    • @thattablebloke
      @thattablebloke 2 ปีที่แล้ว

      @@DaveGrayTeachesCode Great, thanks so much, will have a good look.

  • @ThanHtutZaw3
    @ThanHtutZaw3 2 ปีที่แล้ว

    do I need backend to use react-query-firebase

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      I think you need to be using Firebase which would be your backend - or at least your database. You can learn more about react-query-firebase here: react-query-firebase.invertase.dev/

    • @ThanHtutZaw3
      @ThanHtutZaw3 2 ปีที่แล้ว

      @@DaveGrayTeachesCode I make Todo app with only React and Firestore onSnapshot. I have getting data delay about 1.3 second

  • @mohamedyoussef8835
    @mohamedyoussef8835 ปีที่แล้ว

    Awesome video as always ++++++++++++++++ 🙂

  • @samiullahsheikh5015
    @samiullahsheikh5015 2 ปีที่แล้ว

    Does it make sense to be ReactJS developer but not to be css expert?
    I mean css it's self is way more complex with responsiveness and pixel perfection.
    While css expert struggling in integration of payment gateways, and other 3rd party services etc a ReactJS developer could be much more comfortable in those things

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      You don't have to be a CSS expert. It does help to know the fundamentals. Likewise, a CSS expert does not need to be a JS expert, but it also helps a CSS expert to know JS fundamentals.

  • @danieljing9319
    @danieljing9319 2 ปีที่แล้ว

    nice content, can we have a interval fetch with react-query?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you, Daniel 🙏 I think you may be referring to auto-refetching: react-query.tanstack.com/examples/auto-refetching

  • @nawazishali274
    @nawazishali274 2 ปีที่แล้ว

    Ohh yes just awesome plz perform CRUD with react query in easy way..

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      That is what this video is about. React Query with easy CRUD examples.

  • @codernerd7076
    @codernerd7076 2 ปีที่แล้ว +1

    Redux is created by an team, and does fix two React app problems, while Redux Query is an one dev show, if something happened to this dev or maybe one day when he lost interest the package is doomed. Next to that unlike Redux your api code is all over the place...

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Good points! Yes, React Query offers more flexibility (less opinionated) but that does put some code a bit more "all over the place" as you say. I like using Axios with it, but I really like the more opinionated organization of RTK Query. I'll likely use both depending on the project. Enterprise/production for work will definitely be modern Redux and RTK Query.

  • @abba3261
    @abba3261 2 ปีที่แล้ว

    i remove redux from my life . react query is so useful

  • @acehanks
    @acehanks 2 ปีที่แล้ว

    Something really small, no need to await from the return statement.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Good catch! So for anyone reading - outside of a try/catch block "return await" is redundant. It doesn't hurt anything but is unnecessary. I have "return await" on the addTodo, updateTodo, and deleteTodo. The await can be removed there. Do not remove it from getTodos though! Good article on this from Jake Archibald here: jakearchibald.com/2017/await-vs-return-vs-return-await/

  • @SG48907
    @SG48907 2 ปีที่แล้ว

    Damn, it's still too slow at 1.5x speed 🤦‍♂

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      I have also been asked to slow down. Summary: I will never please everyone as each person has their own preferences.

  • @ahamisi
    @ahamisi 2 ปีที่แล้ว

    Yes, Next Js + Typescript 🥲

  • @ProjectNation99
    @ProjectNation99 ปีที่แล้ว

    i didin't understand how did you increment the id without adding it to the todo :
    addTodoMutation.mutate({ userId: 1, title: newTodo, completed: false })