MERN Stack Project with React Redux and RTK Query

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

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

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  2 года назад +3

    Part 6 of The MERN Stack Project Series - This video focuses on the building the React app for the frontend of our MERN Stack. We will set up Redux and RTK Query in this video. This tutorial is not for beginners. If you are a beginner, check out my full courses all in one playlist here: ruclips.net/p/PL0Zuz27SZ-6M1Uopt6_VL3gf3cpMnwavm

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      @jabin v Yes, I do cover that as this series continues. The default duration to unsub is 60 seconds. We can set keepUnusedDataFor to change that setting in the slice. Keep going and you will see how I keep the notes and users subscribed and available as needed.

  • @sherebiahtishbi
    @sherebiahtishbi 2 года назад +5

    What an in-depth teaching of a complex subject like RTK with all its intricacies!!! Can't believe you are doing this all for free! There are many redux videos and none of them is as advanced as yours. God bless you, Dave.

  • @stevereid636
    @stevereid636 2 года назад +1

    OMG! 🤯 "Multiple cursor case preserve" has changed my life. Thank you so much! 🙏🏾

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Glad it was helpful! It changed mine when I found it, too! 💯

  • @mrbilchalan
    @mrbilchalan 2 года назад +10

    I am surprised that you are doing this for free. Yes, some people has deep knowledge but everyone doesn't possess the teaching style.

  • @stevereid636
    @stevereid636 2 года назад +3

    I can't express how grateful I am that you created this awesome series covering stuff that almost all other instructors miss out, and is SO important when it comes to holding your own in a dev job.
    Could you clarify one thing, Is the implementation of "ValidateStatus" correct? Typescript was complaining, so I checked the docs and it looks like it should be set as an option in the "query". 🤷🏾‍♂

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Hi Steve, I think you are asking about the query option validateStatus. Let me know if I'm mistaken. The docs touch on it here: redux-toolkit.js.org/rtk-query/api/fetchBaseQuery#handling-non-standard-response-status-codes

    • @stevereid636
      @stevereid636 2 года назад

      @@DaveGrayTeachesCode Yes, that is what I'm referring to. You've implemented it differently and I was wondering it was deliberate as the type definitions say that "validateStatus doesn't exist there? 🤷🏾‍♂

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      @@stevereid636 I just checked the link I provided, and I'm not sure what I have implemented differently? It is a property of the builder.query object. The example of validateStatus and my code look the same to me?

    • @stevereid636
      @stevereid636 2 года назад +1

      @@DaveGrayTeachesCode In the docs, it says "validateStatus" belongs in the "query" property. In your code "query" just returning the url string? But it's no biggie really, I was just trying to gain a better understanding.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      @@stevereid636 I see! Good catch! This is honestly something I missed and will revisit in the "refactor" phase before deployment! I will likely simply remove validateStatus as our REST API does provide standard responses.

  • @andrewclarke6916
    @andrewclarke6916 2 года назад +3

    I was racing through this project until I got to this part about configuring the Redux store. It looks like I've missed studying the final three chapters of your React Redux course, Dave! Back to the Blog project for me 😭

  • @Software-ns9li
    @Software-ns9li Год назад +1

    I love the content, very good how everything is being taught, only thing i will say is that since this episode i am kinda discouraged to continue watching cause its becoming like every other tutorial, "let me paste this here" "let me paste this there" etc etc, i understand its for time saving and that we can find your code on github, but for interactive experience its terrible, the initial way of up until this lesson was absolutely perfect

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

      Depends who you ask as I have also received replies that they like this better. I'll never make everyone happy. Enjoy!

  • @davidho3628
    @davidho3628 2 года назад +1

    Hi Dave, been watching your videos for quite some time, you are the best tutor in web dev that I could found on youtube. Thanks for all the great tutorial. Also, will you consider teaching typescript at any time soon?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +3

      Thank you for the kind words, David! 🙏 Yes, a Typescript series is coming very soon! 💯

  • @ameyadongare7380
    @ameyadongare7380 2 года назад +3

    Hi Dave, I am huge fan of your work . If possible do consider making tutorial on Advanced Mongoose/Mongo for insane amount of data for eg (RUclips, Insta, etc). Waiting patiently for same.. fingers crossed :).. Thanks again for the content so far. Will surely buy you a coffee ☕

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

    Your stuff is too good. Thanx for the content. It's exactly what I wanted.

  • @siddiqahmed3274
    @siddiqahmed3274 2 года назад

    Your tutorials are really wholesome. Thanks SIR 🙏

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

    You are excellent teacher!!!!

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

    Hey , just wanted to say i'm really enjoying the series so far but i am curios why do you still choose to use Redux for state management over the React hooks approach which seems to be more common practice now ? is it just preference at this point or performance or something else ? would love to hear your thoughts

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

    good day mr.dave...is it a must that the react(frontend)needs the backend to function properly

  • @kevl7129
    @kevl7129 2 года назад

    Hi Dave thanks again for a great video, will this series or a future tutorial cover how the auth process can be integrated with RTK query?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Hi Kev - yes, it will. Earlier in the series I mention that the goal here is to get the app functioning and then apply the login and protected routes. We are very near to that point of the series now! 🚀

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

    I followed your Redux and RTK tutorial right when you suggested it here and it definitely helped! Something I think I missed there and here...when setting the tags, what does 'LIST' do? Is that an inherent option that tells RTK to do something? If so, is there a reference list somewhere of other options?

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

      You define LIST so you can invalidate the complete list with it.

  • @Ekko-d7o
    @Ekko-d7o Год назад +1

    help . . . how to create new note with postman ? i m trying { "user":"__userId__", "title":"hello","text":"this is hello" } . sending request taking a really long time . other methods are working fine.

    • @Ekko-d7o
      @Ekko-d7o Год назад +1

      i commented noteSchema.plugin(AutoIncrement and it working fine. ????🤷‍♀🤷‍♀

  • @vicsmith7006
    @vicsmith7006 2 года назад

    Thank you for making it so easy to follow along. Better than my professor. Could you make Java tutorials ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Thank you, Vic! No immediate plans to cover Java here, but I won't say never.

  • @therealdevopsintern
    @therealdevopsintern 2 года назад

    When I saw RTK Query I was like surprised how Dave gray dive quickly into using the approach. Nice one Dave but would have preferred Redux and Redux toolkit without RTK Query. Anyways I have already seen your video on RTK Query.
    Just wondering how others who are just getting to know Redux and Redux Toolkit will take in this new concept of RTK Query.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Hi Kelvin - I assume by Redux Toolkit with RTK Query, you prefer creating async thunks to make the API requests. RTK Query is part of Redux Toolkit now, and I see it as providing a separate API layer which is a good thing. Of course, you can get by without it if you want to.

    • @therealdevopsintern
      @therealdevopsintern 2 года назад

      Exactly, you have said it all... I'm using async thunk at the moment to rewrite the project

    • @draicor
      @draicor 2 года назад

      @@therealdevopsintern but you would be missing the point.. using RTK query on this project allows the app to 'refresh/update' the content of certain areas once there has been a change in them.. thats one of the advanced things RTK query does for us without having to code it.. that way the user won't have to refresh the page to get the most updated content..

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

    How did you assign the notes ?

  • @hernanbphb
    @hernanbphb 2 года назад +2

    so.. at the end of the video, why the username says Open or Completed? shouldn't that be the status ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Please compare to my source code at the course resources link in the description. My username data does not hold open or completed. That is a separate field.

    • @draicor
      @draicor 2 года назад

      yea, its a typo on the NotesList.js on line 32, on the JSX table head.. should be Status..

  • @mohammadsamiur4916
    @mohammadsamiur4916 2 года назад

    Dear Sir, Love you from Bangladesh

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

    Sir,
    RTK query is difficult to write. Is there any big benifit to use it in place of axios data fetching . Axios is more time saving and easy to write.which you like most?

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

      Axios is used only as a fetch replacement. RTK Query is more than that. It caches data and is used for state management. That is needed in this project.

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

      @@DaveGrayTeachesCode Thank you for your reply ❤

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

    Hi Dave, amazing classes! One question... does just using the 'userid' referenced in Notes collections allow using 'note.username'?

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

      I would need to review the code to remember, but you can answer this quickly by checking the Note schema to see if a Note has a userId property and a username property.

    • @roysheppard-dev
      @roysheppard-dev Год назад

      This stumped me as well I checked his repo and he adds code to the getAllUsers controller to add the username to the returned JSON.

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

    hey dave...your videos have been a great help to me,but my backend and frontend localhost can't work together,i have to stop one for the other one to respond

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

      My only guess is that your computer may be running out of memory for your dev environment?

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

      how much can this affect because nothing is showing when i open my notelist also in my frontend,does the memory also affect that process too?@@DaveGrayTeachesCode

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

    why my grid is empty and it is not showing any data can anyone please say

  • @zaidclsn6208
    @zaidclsn6208 2 года назад

    Can you do a tutorial on PDF generation using node js? Or is there any library which you can suggest? Thanks

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Thanks for the request! A quick search of npmjs.com shows this top result: www.npmjs.com/package/pdf

  • @adarshalone7579
    @adarshalone7579 2 года назад

    This was great.... Dave Sir

  • @takisnani5337
    @takisnani5337 2 года назад

    Hi dave thanks for your efforts!
    Please how can we grab the username from note, We only store the user key with id of the user (in the Note.js)

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Yes, this is because our data is normalized with the entity adapter. You can check my source code at the link in the description to see how I did it. You grab the data by using a selector in the note component.

  • @Clash-Roblox
    @Clash-Roblox Год назад

    I can't POST notes to database, It keep loading not stop.

    • @kingsleyobi-ko9zj
      @kingsleyobi-ko9zj 8 месяцев назад

      For people having the same issue:
      If you are trying to create a new note and Postman just hangs:
      It is because mongoose-sequence is no longer supported, and doesn't work with mongoose 7+.
      Replace mongoose 7+ with mongoose 6.12.0 by entering
      "npm install mongoose@6.12.0"
      Then make sure that your package.json & package-lock.json say "mongoose": "^6.12.0"

  • @dhavalvanjara572
    @dhavalvanjara572 2 года назад

    @Dave Gray will you please share the list of extension installed in vscode. It would be great. I saw 39 extension was installed.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      That number is not a count of my VS Code extensions. It is the number of file changes for git. In the course resources, there is a section that shows several of the VS Code extensions I frequently use. 🚀

    • @dhavalvanjara572
      @dhavalvanjara572 2 года назад

      @@DaveGrayTeachesCode Number of files change was 48 that is different. I am talking about extension part. Just curious to know useful extension which can boost the productivity. Just asked out of curiosity. Feel free to share else ignore.

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

    HI Dave - I've followed your course and have been creating MERN stack applications of my own. I keep having bugs though with the feature slices, specifically with the selectors created by the created adapters with getSelectors. For example I have a feature called Areas and useGetAreasQuery works fine. But selectAllAreas doesn't work. I have another feature Plantings but selectPlantingById doesn't work. Is there a guide to debugging these? Are there common issues that trip people up? I'm not seeing error messages, just not getting data returned.

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

      There is some good documentation on the official site: redux-toolkit.js.org/ ...that said, I see you are not all the way through this series. By the end, I do a refactor to only use the RTK Query hooks.

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

      @@DaveGrayTeachesCode yes it's true. I got about up to the JWT part - figured I'd tackle that once I had the "slice" queries and selectors part down better. Also gonna review your other series on the reduxjs toolkit with react - see if that helps. Thx

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

    Hi Dave. I have a issue which is slightly confusing me. While creating a note using postman, the postman just gets stuck at loading. But this happens when I use mongoose version 7.0.3. But when I downgrade it to 6.0.5, the one that you have used in the course, it works fine. If possible , can you provide an alternate solution? I searched a lot for the solution, but couldnt find it.

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

      In my Discord, some devs have noted that the dependency mongoose-sequence does not work with Mongoose 7. You discovered the fix. By rolling back Mongoose to v6, it works together.

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

      @@DaveGrayTeachesCode Thank you .😃

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

    Why can I not post to "/notes" endpoint?

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

      Look at the update in the comments or description of Video #3 in this series.

  • @kingsleyobi-ko9zj
    @kingsleyobi-ko9zj 9 месяцев назад

    Please,I have been trying to add to my notes,but it’s not responding,please help

  • @sailee5208
    @sailee5208 2 года назад

    Hi Dave, I am trying to post a note in Postman, but the error message is passing back 'all fields required'. I have created a raw JSON with user (with id from created user) title, text, and completed fields. What am I missing? TIA Sai.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      I can only guess about what is different in your code. You can view my source code in the course resources to compare. Pay special attention to the backend endpoint controller that expects to get specifically named fields and returns that error when it does not. Insure your frontend code matches those specific data names.

    • @sailee5208
      @sailee5208 2 года назад +1

      @@DaveGrayTeachesCode Thank you Dave! Was not a coding error. I did not change the tag from 'text' to 'json' in Postman. All working correctly now. Thank you for all your tremendous content!

  • @anis213_40
    @anis213_40 2 года назад

    Thank u Dave !

  • @AhSoh7091
    @AhSoh7091 2 года назад

    Hi Dave, I try to move it into NextJs , the API return status 304 instead of 204 or 200. It will be work in different way in NextJs?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Consider Googling http status 304. Next.js is different from this app. You will likely have to adjust several things.

    • @AhSoh7091
      @AhSoh7091 2 года назад

      @@DaveGrayTeachesCode thanks sharing your thought and time.

  • @lekkyjayz6294
    @lekkyjayz6294 2 года назад

    I wish this tutorial was done with typescript.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Maybe another one in the future. Typescript series coming very soon. 🚀

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

    Where can I get tutorial for RTK Query, I'm lost here

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

      Course resources link. Then in the README find the prerequisites and the link to Redux Toolkit course: github.com/gitdagray/mern_stack_course

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

      @@DaveGrayTeachesCode many thanks

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

    Hello.
    First of all, thank you very much Sir Dave Gray.
    You're awesome teacher.
    I got an error during rewrite your code.
    The error is:
    {
    "message": "Cast to ObjectId failed for value \"64c2b9795b2d842b5b692999\
    \" (type string) at path \"_id\" for model \"User\""
    }
    Anyone help me, please?
    Thank in advance for any helping.
    Happy coding.

    • @kingsleyobi-ko9zj
      @kingsleyobi-ko9zj 8 месяцев назад

      is it happening on your postman or your vs code

  • @tanishqa-sv
    @tanishqa-sv Год назад

    I'm trying to create a note by sending {
    "user": "645bxxxxxxxxxxxxxxxx188d",
    "title": "title",
    "text": "description"
    } to /notes
    but postman is stuck at "Sending request..."
    and at this line of code: const note = await Note.create({ user, title, text })
    I checked the code is almost the same as Dave's so I suppose is there a different way I should send the request?
    I have tried a few things but can't seem to get through.

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

      Did you check your Node.js console for an error? Sounds like there must be one.

    • @tanishqa-sv
      @tanishqa-sv Год назад

      @@DaveGrayTeachesCode There is no error in the log files or console.
      Commenting out this piece of code is making it work:
      noteSchema.plugin(AutoIncrement, {
      inc_field: 'ticket',
      id: 'ticketNums',
      start_seq: 500
      })
      but I shouldn't?

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

      @@tanishqa-sv did you figured it out already? I face the same problem here

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

      ​@@muhammadaiman8772 @tanishqa-sv Kindly check your package.json, If the mongoose version is > 7.x.x then one quick solution would be to downgrade the mongoose version to ^6.x.x
      You can run the below steps:-
      1. npm uninstall mongoose
      2. npm i mongoose@^6.5.0 (This is the version used in Dave's package.json)
      It will work with this, however, this is a quick workaround, Would need to dig into why it isn't working with latest version, will give an update on it later.

  • @eurogamestyle5761
    @eurogamestyle5761 2 года назад

    Thanks 🙏

  • @nxshipon6470
    @nxshipon6470 2 года назад

    Next content Mongoose 🥰

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Hi! I cover Mongoose for this project in lessons 3 & 4. I cover it in more detail in my Node.js course listed as a pre-requisite in the video description, too. 🚀

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

    25:50

  • @7doors847
    @7doors847 2 года назад

    TOP!

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

    {2023-02-28}

  • @jiweihe3413
    @jiweihe3413 2 года назад

    Thanks for the great tutorial! 7:30 const initialState = usersAdapter.getInitialState(). I notice we don't need to provide any initial state. Is that because we are using default values for everything including isLoading etc?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      The initial state in this example at 7:30 comes from the entity adapter which is referred to as usersAdapter. You can see just above that we set it to an empty object at first. After we fetch data, the object will hold an ids array and an entities array.

  • @AhSoh7091
    @AhSoh7091 2 года назад

    Guys, how can we select value according once the state value is changed in useGetUsersQuery(‘stateValue’) and updated accordingly the usersApuiSlice.endpoints.getUsers.select(“valueWillChangeIfStateUpdate”)
    Because I’m passing query in the useGetUsersQuery(‘valueWillChange’)
    If the select() is empty or hardcore value that cannot retrieve the correct cached value from the redux store once the state is updated

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      There is a refactor lesson later in this series that switches to a full implementation of RTK Query. My suggestion is to keep going with the project as-is and you will see how it all comes together.

    • @AhSoh7091
      @AhSoh7091 2 года назад

      @@DaveGrayTeachesCode Ok. I learn a lot from this channel. Thank for your time to created all the videos.

  • @nxshipon6470
    @nxshipon6470 2 года назад

    Thank you sir