React Redux Tutorials - 10 - Combine Reducers

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

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

  • @Nate5466
    @Nate5466 3 года назад +21

    This channel is very underrated. Its a full course....not some preview crap that is basically an hour long sales pitch. Appreciate you bother!

  • @parrou3
    @parrou3 4 года назад +40

    Even paid courses don't make things clear as you did ; in one word awsome, thank you

  • @xhpfanx
    @xhpfanx 3 года назад +17

    Who else here feels like Redux is making them their brains explode? I've watched 4 other videos trying to learn it already .... this one is really helpful for sure!

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

    What a crisp and precise content. Just a basic example with full focus on concepts. Superb. Keep going Vishwas.

  • @flokipanda
    @flokipanda 3 года назад +1

    I know little bit about redux but after watching your redux series I get very good grasp of redux. And your example of cake shop is really amazing.

  • @shivakc9965
    @shivakc9965 3 года назад +1

    NO one can make things as easy as you made in this and every other courses. You're pretty amazing.

    • @Akira-sh7ts
      @Akira-sh7ts 3 года назад

      Hi there are too many playlist on react on this channel from which playlist should I start as beginner

  • @prateek4524
    @prateek4524 3 года назад +4

    I can't thankyou enough. You're a savior bro. Explaining everything with such great simplicity and clarity. I love all of your videos. Thankyou sooo muchhh.

  • @manee427
    @manee427 3 года назад

    The Best Redux Explanation .Perfect

  • @rp2804
    @rp2804 4 года назад +2

    Great respect fpr this tutorial. You don't need to rename your reducers while combining in an object, you can just write original names with comma in between and it will still work

    • @hd3adpool
      @hd3adpool 4 года назад

      Bro, you could've said that without mentioning the lizard thing. Why you wanna make me cringed out!

    • @rishabhdas5576
      @rishabhdas5576 3 года назад

      Yes, but that is an ES6 method of destructuring.

    • @Jason-uv5tm
      @Jason-uv5tm 3 года назад

      But honestly, I wouldn't want to have "cakeReducer" as a object name, because it doesn't make sense to people viewing the object, because it isn't a reducer, it is an object containing the number of cakes.

  • @prasunkj
    @prasunkj 3 года назад +3

    redux was never so easy!! thanks a ton!!

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

    I I were a billionaire I would have asked him to join my company as a ceo man you are so good you have prepared the lectures in a proper manners thanks a million

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

    Really my impression level is Infinity. I have checked too many tutorial but Everytime I Was confused . why sometimes they used reducer and rootreducer together. But you are the best teacher 💘💘💘 You are amazingly the best. Lots of thanks & wishes 🥰

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

    Thank you for this amazing explanation. You really made it very simple

  • @_rachid
    @_rachid 4 года назад +4

    Thank you .. Now I understood how Redux works, that was so clear.

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

    I dont have words.......GREAT WORK MAN

  • @satyasahoo26
    @satyasahoo26 4 года назад +4

    Feeling like redux s so easy,thank you Sooooooo much.

  • @karlleung2102
    @karlleung2102 4 года назад +6

    Hi, thank you for the amazing tutorials
    Before splitting into multiple reducers, I added number of Transaction in my state.
    initialState = { numOfCake: 10, numOfIcecream: 20, numOfTransaction: 0};
    in the single Reducer, I will always add 1 to numOfTransaction for each action
    I have a question after splitting into multiple reducers,
    how to I share/keep track on the numOfTransaction information between two reducers?
    Thank you again.

    • @yashgupta8734
      @yashgupta8734 3 года назад +3

      If we have a third reducer, which responds to both actions and increases transaction state by 1,maybe that would work?

  • @isakawilliam
    @isakawilliam 3 года назад

    i rarely comment on videos, but bro..you make learning really easy tbh

  • @nikoblading
    @nikoblading 3 года назад

    I love Maltese accent, had so many colleagues from there :-P

  • @Webdev5550
    @Webdev5550 3 года назад

    Love you bro for easy explanation

  • @Jason-uv5tm
    @Jason-uv5tm 3 года назад +1

    2:48 is wrong, the action does not ignore it, it does stuff to it (you can even add a console.log to check if that is true, which it is).

  • @piyush9555
    @piyush9555 4 года назад +3

    2:48 it doesn't ignore it, if any action.type is present there, it'll act upon it.

    • @LetCode96666
      @LetCode96666 4 года назад +2

      What happens to non specified actions then? I mean what did Vishwash say wrong?

    • @mm333-e1t
      @mm333-e1t 3 года назад

      So basically action.type should not be same ?

    • @Jason-uv5tm
      @Jason-uv5tm 3 года назад

      @@LetCode96666 What do you mean by non specified actions? Also, what Vishwas said was that one reducer will ignore the action.type, but that is not true. It will act upon it. Try console.logging in side the other reducer, and see what happens. It will be called, and the switch statement will be acted upon, going to the default case.

    • @Jason-uv5tm
      @Jason-uv5tm 3 года назад

      @@mm333-e1t What is the same? We are using BUY_CAKE and BUY_ICECREAM, which aren't the same

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

    Make things seems and look so easy

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

    The tutorial was presented with great clarity. Thanks, Vishwas
    {2022-09-27]

  • @MuhammadBilal-hq3xn
    @MuhammadBilal-hq3xn 3 года назад +1

    You are inspiration.

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

    awesome course👍😊

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

    How does the action when I call it using dispatch() know which reducer it should use (cake or Ice Cream)?

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

    But Good explanation

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

    With the reducers being splitted, each takes care of just one state, doesn't that mean the action is no longer required, as we don't really need to check the action type anymore?

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

      I am thinking this too but in 2:36 he mentioned that when you dispatch an action, actually both iceCreamReducer and cakeReducer will receive that action. Hence why we must still check for what is the action.type

  • @indraneelpradhan9747
    @indraneelpradhan9747 3 года назад

    Will you do a video with multiple redux store with redux v6

  • @isakawilliam
    @isakawilliam 3 года назад

    please do so some ruby/ ruby on rails series...or paid course even...nodeJS tooo...will be the first to buy

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

    sir if create separate folder for each react and redux

  • @sameerdodai1421
    @sameerdodai1421 3 года назад

    what if we have to perform multiple actions at same time. Like in this example customer wants to buy both cake and ice cream at same time. Not first he buy cake then come again to buy ice cream

  • @syedimam1998
    @syedimam1998 3 года назад

    i have a doubt, what if let say we have action called number and reducer add and mul, and now number action is dispatched then we know both reducers will accept it becoz it action.type requires number(0,1,2,3) now only want add reducer should receive it not the mul then how to do that?????

    • @joeswizat9941
      @joeswizat9941 3 года назад

      Your acction.type/s should be ADD and MUL and your payload the number/s, then you can operate differently with your numbers in your switch

  • @sangtonsing9722
    @sangtonsing9722 3 года назад

    It works on decrement(when buying cake the number of cake decrease) but when trying to increment it malfunctions. Suppose numOfCakes-10 and when we buy it gives us 9 but when incrementing the number instead of giving 11 it gives us 101, 1011, 10111, 101111... Why? is it an intention bug?

    • @kunal9748
      @kunal9748 3 года назад

      But it works for me! Make sure you are using number, it looks like you are getting string concatenation as output!

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

    Hey dont we need Redux thunk to run this?

  • @vaibhawkr3904
    @vaibhawkr3904 4 года назад

    What if the action type are not present in either reducer. Since both reducer is supposed to return the default state when action type not matches.

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

      IT WILL return the initial state for both: Updated state: { cake: { numOfCakes: 10 }, iceCream: { numOfIceCreams: 20 } }

  • @pharmokan
    @pharmokan 4 года назад

    thanks

  • @shahazhanatova2185
    @shahazhanatova2185 4 года назад

    what do i do when my node index command does not work? it keeps throwing error saying cannot find module

    • @Jason-uv5tm
      @Jason-uv5tm 3 года назад

      Assuming you mean node index.js, but anyways, you have to install redux. If you are following the series, it should've been installed. But if somehow it isn't, just run "npm i redux" in terminal. If package.json doesn't exist, then run "npm init" first. (BTW, I'm assuming you mean "cannot find module redux").

    • @shaznanfairoze2008
      @shaznanfairoze2008 3 года назад

      make sure you cd to your working repository

  • @Aouraghmouhamed
    @Aouraghmouhamed 3 года назад

    thanks thanks thanks thanks thanks

  • @subhraswarup
    @subhraswarup 5 лет назад

    Can we create selector for rootReducer

  • @genos2719
    @genos2719 3 года назад

    what is the unsubcribe for ?

    • @chethananderson3446
      @chethananderson3446 3 года назад

      That means you no longer can do changes to the redux store since you have unsubscribed it.

  • @junfengding1591
    @junfengding1591 4 года назад

    what if 2 reducer has two same action.type accidentally?

    • @salemouail627
      @salemouail627 4 года назад +10

      that's why u define them with const on the top
      so u can't declare them twice

    • @DaCurse0
      @DaCurse0 4 года назад

      They will probably both do something then. Try it out.

    • @shabnamnaaz5751
      @shabnamnaaz5751 4 года назад +3

      it will do both the actions , doesnot give error. tried it

    • @Jason-uv5tm
      @Jason-uv5tm 3 года назад

      you mean in both switch statements, both go for e.g. BUY_CAKE? If so, then they will both call the stuff inside the BUY_CAKE case. 2:48 is not true if this is why this confusion occurred. A comment which explains: "it doesn't ignore it, if any action.type is present there, it'll act upon it."

  • @alexmcdonalds1962
    @alexmcdonalds1962 4 года назад

    getting shapeAssertion Error ?

    • @LetCode96666
      @LetCode96666 4 года назад

      nope! Please check your code again

    • @nitishkhanna9368
      @nitishkhanna9368 4 года назад

      Check the states which you have assigned to the state parameters in your reducers

    • @myardanaqiella3910
      @myardanaqiella3910 4 года назад +1

      @@nitishkhanna9368 You must add default case at switch

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

    confusing

  • @sam-rq3cq
    @sam-rq3cq 5 лет назад

    Need a tutorial on react with laravel with authentication sir.

    • @realsandeep
      @realsandeep 5 лет назад +9

      I think you are mistaken. codevolution is not a bartender

    • @sam-rq3cq
      @sam-rq3cq 5 лет назад +1

      @@realsandeep I m requesting him. Not like u.

    • @realsandeep
      @realsandeep 5 лет назад +4

      @@sam-rq3cq of course you are not like me. Everyone are different. I like the way you put requests.

    • @Get_versatility
      @Get_versatility 4 года назад

      @@realsandeep Lol:)))))

    • @dremiq6670
      @dremiq6670 4 года назад

      holy shit my eyes

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

    I have a query,
    createStore is marked as deprecated, after searching about it that redux team has shifted to @reduxjs/toolkit.
    please give solution regarding it

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

    const redux = require('redux');
    const initialCakeState = {
    noOfCake : 20
    };
    const initialIceCreamState = {
    noOfIceCream : 10
    };
    const BUY_CAKE = 'BUY_CAKE';
    const BUY_ICECREAM = 'BUY_ICECREAM';
    const buyCake = () => {
    return (
    {
    type : BUY_CAKE
    }
    );
    }
    const buyIceCream = () => {
    return (
    {
    type : BUY_ICECREAM
    }
    );
    }
    const reducerCake = (prevState = initialCakeState , action) => {
    switch(action.type) {
    case 'BUY_CAKE' : return {...prevState , noOfCake : prevState.noOfCake - 1};
    }
    }
    const reducerIceCream = (prevState = initialIceCreamState , action) => {
    switch(action.type) {
    case 'BUY_ICECREAM' : return {...prevState , noOfIceCream : prevState.noOfIceCream - 1};
    }
    }
    const combineReducers = redux.combineReducers;
    const rootReducer = combineReducers({
    cake : reducerCake,
    icecream : reducerIceCream
    })
    const store = redux.legacy_createStore(rootReducer);
    const listener = () => {
    console.log(store.getState());
    }
    const unsubscribe = store.subscribe(listener);
    store.dispatch(buyCake());
    store.dispatch(buyCake());
    store.dispatch(buyIceCream());
    store.dispatch(buyCake());
    store.dispatch(buyIceCream());
    unsubscribe();
    Can anyone explain what is wrong with the above code i am getting the below error.
    e:\Redux
    ode_modules
    edux\lib
    edux.js:550
    throw shapeAssertionError;
    ^
    Error: The slice reducer for key "cake" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.
    at e:\Redux
    ode_modules
    edux\lib
    edux.js:481:13
    at Array.forEach ()
    at assertReducerShape (e:\Redux
    ode_modules
    edux\lib
    edux.js:474:25)
    at combineReducers (e:\Redux
    ode_modules
    edux\lib
    edux.js:539:5)
    at Object. (e:\Redux\File7.js:42:21)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)