Redux Made Easy | Learn React Redux | Redux Tutorial for Beginners

Поділитися
Вставка
  • Опубліковано 24 гру 2024

КОМЕНТАРІ • 59

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  3 роки тому +5

    I really like Easy Peasy. It is an abstraction of Redux - that is Redux is running underneath it - and Easy Peasy makes the usage...well, easy! Redux can be difficult to learn, but I wanted to add something about in this Learn React beginners tutorial series. If you are just starting out with React, go to the beginning of the Learn React series here: ua-cam.com/play/PL0Zuz27SZ-6PrE9srvEn8nbhOOyxnWXfp.html

  • @chrisstucker1813
    @chrisstucker1813 Рік тому +2

    Context is nice for smaller use cases. But I must say that redux provides a much more robust and organised approach. It sort of makes it easier to envision the various states being managed across different components.
    For instance in the nav component: when you alter the searchResults and send the payload to the Redux store, it then causes a refresh in the home component because that is using the searchResults state. So when you update a state, it gets sent to redux then relayed back the components that use that state then causes a re-render of the component with the updated state. It makes the whole flow of state much easier to follow IMO

  • @rezgui_aziz
    @rezgui_aziz 3 роки тому +5

    Thanks god i found this gentlemen, good job sir keep it up

  • @skillkrio
    @skillkrio 2 роки тому

    Dave in 16:45 you are adding setPosts as dependency list before we didn't added setPosts as dependency list in the context api. Why are we adding setPosts as a dependency over there?

    • @skillkrio
      @skillkrio 2 роки тому

      Hi i think you didn't noticed my comment for better reach i am replying here

  • @metquadi
    @metquadi 2 роки тому +2

    thanks teacher. but I feel React context is much easier to use. I wonder when I need to use easy-peasy ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +3

      It is your preference or your team's choice. Redux is used most often for larger applications with a lot of state to keep track of.

    • @metquadi
      @metquadi 2 роки тому

      @@DaveGrayTeachesCode thank you teacher. I am very grateful to you.

  • @ivanfrey6323
    @ivanfrey6323 2 роки тому +1

    Hey Dave, loving the content. I am a bit confused, do you think you could better elaborate on what the payload exactly is? I feel like your explanation was brief, maybe hearing more from you could clear up the confusion? Thank you!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +3

      Hello Ivan - yes, Redux can be confusing. If you look at the store.js file, you see that we have different actions like setEditTitle that receive the current state AND a payload as arguments. The payload depends on what the action is. For setEditTitle, if we look at the EditPost.js file, the onChange event of the title input allows us to pass in a new title for the post. That is the payload for setEditTitle. In the same way, setEditBody receives a payload that has text for the body of the post. I hope this helps!

    • @ivanfrey6323
      @ivanfrey6323 2 роки тому

      @@DaveGrayTeachesCode Ahhhh I see, so it's essentially like the parameter that will either override the state or be appended to it, I think I get it now. I think payload is just a weird name for it, but I see, thanks a lot Dave.

  • @chammyae9987
    @chammyae9987 2 роки тому +2

    Hello, I follow along this series with no problem but in this one after changing from Context api to easy-peasy, states are not updating. Posts are not showing when I reload. I can't type on form, I can't add post. I can't edit post. Can anyone tell me, what is happening. I'm so confused right now.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +2

      I would only be guessing about your code. Compare your code to the code available at the course resources link in the description.

    • @DoraG0N
      @DoraG0N 2 роки тому

      @@DaveGrayTeachesCode hello sir .. I have the same problem that Cham's has , idk if it's coincidence or may be there is a problem with react v 18 or something, (I'm sure I did the same code as yours and I checked it many times :( .. )

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      @@DoraG0N If you think it is React 18, this video may help: ua-cam.com/video/81faZzp18NM/v-deo.html

  • @skillkrio
    @skillkrio 2 роки тому

    I am commenting again as my previous comment didn't get noticed Dave in 16:45 you are adding setPosts as dependency list in App.js and also adding setSearchResults in Nav.js before we didn't added setPosts/setSearchResults as dependency list in the context api. why are we adding that?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      I'm not entirely sure what you are asking - but I'll attempt to answer. We are using Easy Peasy Redux here and not Context. When you say "dependency", it makes me think of the dependency array in the useEffect hook - and maybe that is what you are referring to. You do not need to add the setState function (whatever it is named... setPosts, setSearchResults, etc) as a dependency in useEffect in the current version of React (currently v18). In the past, you didn't need to either BUT React would provide a confusing dependency warning saying that you did need to... so I just included them. If not, I would likely have had many questions about that warning. So to sum up, you can skip putting any setState function in the dependency array for useEffect. I hope I answered the right question.

    • @skillkrio
      @skillkrio 2 роки тому

      @@DaveGrayTeachesCode why are you adding setPosts in the dependency list? It's just a useStoreActions in 16:45 time frame. During that video you told that ohh we need to add this because react complaints us to add like that

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      I just answered this question in my first reply?
      Quoting it here: "You do not need to add the setState function (whatever it is named... setPosts, setSearchResults, etc) as a dependency in useEffect in the current version of React (currently v18). In the past, you didn't need to either BUT React would provide a confusing dependency warning saying that you did need to... so I just included them. If not, I would likely have had many questions about that warning. So to sum up, you can skip putting any setState function in the dependency array for useEffect. "
      Also, to insure your questions are answered and seen, please join my Discord: discord.gg/neKghyefqh

    • @skillkrio
      @skillkrio 2 роки тому

      Thanks alot Dave i feel like incomplete after finishing the series. Now makes sense. Thankyou so much Dave

  • @sakibcoder
    @sakibcoder 2 роки тому

    CONGRATS FOR 100K

  • @LiranUziel
    @LiranUziel 2 роки тому

    Tip: new way of state management do on a new project. this change made me look 100 times at every line to make sure i wrote it right.

    • @LiranUziel
      @LiranUziel 2 роки тому +1

      plus filteredResults return empty array for me :(

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      Compare your code to my source code to find the differences. Source code available in the resources.

    • @zman7357
      @zman7357 Рік тому

      @@DaveGrayTeachesCode mine was also returning an empty array, I cloned the chapter 22 repo, ran npm I, but then when I run npm start I get the error: Error: error:0308010C:digital envelope routines::unsupported.

  • @sonamohialdin3376
    @sonamohialdin3376 2 роки тому +1

    Amazing tutorial

  • @olimeunier
    @olimeunier 2 роки тому

    Thank you Dave for this video. Nothing works anymore with React Router V6...

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      You're welcome - In the course resources, I shared an update to this blog project for RRv6. Here is a link: ua-cam.com/video/XBRLVRjZ3CQ/v-deo.html

  • @shoaibkhan-eq8vp
    @shoaibkhan-eq8vp Рік тому

    Heyy guyss, can somebody help me! I followed this tutorial step by step but I'm getting an unknown error like their is not error message but the app is not visible. As I'm using latest vision of react router. I made a file called layout and in that file I use Outlet In between nav and footer. I think I'm unable to understand the syntax of easy peasy merging into react router (virsion 6), Is their anyone who can help me??

  • @코린이31세
    @코린이31세 3 роки тому +2

    Amazing contents sir!!!, thank you very much

  • @Ruhgtfo
    @Ruhgtfo Рік тому

    Failed to load resource: the server responded with a status of 404 (Not Found) >< help

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Рік тому +2

      Sounds like you need to start json-server.

    • @Ruhgtfo
      @Ruhgtfo Рік тому

      @@DaveGrayTeachesCode will try after thanks for sharing ~ :D

  • @samiullahsheikh5015
    @samiullahsheikh5015 2 роки тому

    Can someone just use utility function (regular function) instead of custom hook like your useAxiosFetch() for api call?
    And can return arry of data, error and loading
    Return [ data, error, loading]

    • @samiullahsheikh5015
      @samiullahsheikh5015 2 роки тому

      And that function can be used in thunk as well

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      It is Javascript, so yes, you can create a function. Thinking in a Reactful way, it is preferred to create a hook. Hooks do have some benefits in React. This video dives deeper into creating Axios hooks: ua-cam.com/video/NqdqnfzOQFE/v-deo.html

  • @dafiraone
    @dafiraone 2 роки тому +1

    I have a question, how do you manage your directory & file names with camelCase/capital? is there any rules for naming?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      It can depend on the team and project. Go with the rules of your dev team at work. For your own projects, many approaches can be used. I should create a video for this 🚀

  • @elAmigo805
    @elAmigo805 Рік тому

    I keep getting the following error but I can't trace it anywhere:
    Home.js:12 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at Home (Home.js:12:1)
    all I have there is the {fetchError} in the p element that is inside the :
    {!isLoading && fetchError && (

    {fetchError}

    )}
    Anyone else resolved this issue?

    • @miq_5239
      @miq_5239 9 місяців тому

      Hey, I have the same problem. Did you fix it by any chance?

    • @elAmigo805
      @elAmigo805 9 місяців тому

      I think I had destructured searchResults instead of leaving it as a const variable. It was a simple mistake for me. Not sure if you have the same scenario. I should've had this:
      const searchResults = useStoreState((state) => state.searchResults);
      but I had this instead:
      const { searchResults } = useStoreState((state) => state.searchResults);

    • @OlaRsk
      @OlaRsk Місяць тому

      Me too

  • @spicythunder4462
    @spicythunder4462 3 роки тому +1

    Thank You.

  • @abdulrahmanagboolaosho3582
    @abdulrahmanagboolaosho3582 2 роки тому

    Could you please do a react native tutorial

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      I want to do this. It will be next year sometime before I get the chance.

  • @DeepakGupta-hj2dv
    @DeepakGupta-hj2dv 3 роки тому +1

    please make on video redux thunk crash course

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 роки тому +1

      Thanks for the request! 🙏

    • @DeepakGupta-hj2dv
      @DeepakGupta-hj2dv 3 роки тому

      @@DaveGrayTeachesCode please also make a video redux saga and redux toolkit crash course

  • @kylesheen7432
    @kylesheen7432 2 роки тому

    Pros and Cons of Redux vs Context?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      Good question, Kyle - The answer could probably be its own video. TLDR: Context is built-in and simpler. I would use it for simple and medium-sized projects. Easy peasy redux is the easiest version of Redux I have seen. You could also use it for small and medium projects. Redux toolkit is only for large complex state management. You would see it in Enterprise level projects.

  • @benedictmoeti5162
    @benedictmoeti5162 Рік тому +1

    Too much information. This video should be labelled "for intermediate to advanced users". Not for beginners

  • @salehm5413
    @salehm5413 2 роки тому

    If I used only easy peasy that mean I don't need to use redux !