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
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.
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 :)
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?
@@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' }
@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. [' ']
You my friend are an excellent teacher and a great series this is. Thanks a lot!
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
love u bro no homo
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;
@@farazmobin2776 Thank you! - This was a big help. August 2024
@@gregboyd6216 you’re welcome
This saves me from the mind-boggling RTK tutorials. Thanks a lot!
Reading REDUX was a plus
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.
You are doing god's work. Thanks👍
thanks for help, managed to complete my task after watching your video
Such an Amazing playlist it is!
By far the best Redux tutorial, thank you
i hope so xd
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 :)
the map extraReducers way has been removed use the builder way guys
Thank you !
OMG! I totally understood that.
gracias!
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?
no it shouldn't as we are only working with "ordered" action from cakeSlice
What is the meaning of sytax ['cake/ordered'] or as explained function in square brackets
He explained it on Redux Toolkit Tutorial - 22 3:38
Read about Map and Set in js. That's what you asked for, I suppose. Array or object can be key in Map
@@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'
}
['Name/ReducerName']
@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. [' ']
Is it possible to use logger for extra reducers ?
@Codevolution ??
Great video. Any idea how to separate content inside extrareducer to another file?
Awesome +++++++++++++++++ 😃
Thank You So much