Redux Toolkit Tutorial - 23 - Extra Reducers

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

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

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

    You my friend are an excellent teacher and a great series this is. Thanks a lot!

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

    if anyone is getting this error in dec 2023,
    throw shapeAssertionError;
    ^
    Error: The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead.
    use this,
    extraReducers: (builder) => {
    builder.addCase('cake/ordered', (state) => {
    state.numOfIceCreams--
    })
    }
    instead of this,
    extraReducers: {
    ['cake/ordered']: (state) => {
    state.numOfIceCreams--
    }
    }
    thank me laterhand-pink-waving

    • @Alex-xe6bl
      @Alex-xe6bl 9 หลายเดือนก่อน

      love u bro no homo

    • @farazmobin2776
      @farazmobin2776 7 หลายเดือนก่อน +6

      fix:
      const { createSlice } = require("@reduxjs/toolkit");
      const initialState = {
      numberOfIceCreams: 10,
      };
      const iceCreamSlice = createSlice({
      name: "icecream",
      initialState,
      reducers: {
      ordered: (state) => {
      state.numberOfIceCreams--;
      },
      restocked: (state, action) => {
      state.numberOfIceCreams += action.payload;
      },
      },
      extraReducers: (builder) => {
      builder.addCase("cake/ordered", (state) => {
      state.numberOfIceCreams--;
      });
      },
      });
      module.exports = iceCreamSlice.reducer;
      module.exports.iceCreamActions = iceCreamSlice.actions;

    • @gregboyd6216
      @gregboyd6216 5 หลายเดือนก่อน +2

      @@farazmobin2776 Thank you! - This was a big help. August 2024

    • @farazmobin2776
      @farazmobin2776 5 หลายเดือนก่อน

      @@gregboyd6216 you’re welcome

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

    This saves me from the mind-boggling RTK tutorials. Thanks a lot!

  • @SandeepPrajapati-xu9ru
    @SandeepPrajapati-xu9ru 8 หลายเดือนก่อน +1

    Reading REDUX was a plus

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

    The best Redux Toolkit Tutorial in TH-cam. So far i have gone through several TH-cam channels to learn Redux but no explain it in details as You do. thanks a lot.

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

    You are doing god's work. Thanks👍

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

    thanks for help, managed to complete my task after watching your video

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

    Such an Amazing playlist it is!

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

    By far the best Redux tutorial, thank you

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

    Thank you so much, I'm following the videos and they are super clear and easy to understand!
    btw: I think (in my opnion) the first way to write the the extraReducers, is makes more since to me, and it's easier to understand.
    for me I think that if I don't need to use the functionality provided by (builder), and all I need is just to add Extra Reducer, I'm gonna stick with the first way :)

  • @jivara5523
    @jivara5523 11 หลายเดือนก่อน +5

    the map extraReducers way has been removed use the builder way guys

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

    Thank you !

  • @sunflair-wa
    @sunflair-wa 2 ปีที่แล้ว

    OMG! I totally understood that.

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

    gracias!

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

    for extra reducers, when the cake is ordered, the number of ice-cream is reduced by one, what about when cake is restocked, does the number of ice-cream reduce too?

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

      no it shouldn't as we are only working with "ordered" action from cakeSlice

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

    What is the meaning of sytax ['cake/ordered'] or as explained function in square brackets

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

      He explained it on Redux Toolkit Tutorial - 22 3:38

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

      Read about Map and Set in js. That's what you asked for, I suppose. Array or object can be key in Map

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

      @@bloon1k That's not a map bro, that's computed values. for instances something like this const o = {
      ['hi']: 24,
      name: 'potato',
      }
      will be computed as {
      hi: 24,
      name, 'potato'
      }

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

      ['Name/ReducerName']

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

      @prince5922 Thanks! oh uh! Got to learn a basics coz of all of ur conversations.
      - it is not a map (key-value pair like in java). it is JS object.
      - it is not an array. it is Computed property for the key of that js object. [' ']

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

    Is it possible to use logger for extra reducers ?
    @Codevolution ??

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

    Great video. Any idea how to separate content inside extrareducer to another file?

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

    Awesome +++++++++++++++++ 😃

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

    Thank You So much