Hello there,
I’m finishing the Redux module and just completed the Redux Counter Challenge after a little help checking old forum posts but I’m having a little trouble figuring something out: who creates state?
I understand store is where the state lives and reducer affects state given certain actions but how is state created? Right now my best guess is that state is created in the reducer parameters (I believe that’s what I did in my counter) but in that case, what if I wanted to have state saving 2 different counters? How could I do such a thing?
Here’s my counter reducer:
const counterReducer = (state = 0, action) =>{
switch(action.type){
case INCREMENT:{
return state+1
}
case DECREMENT:{
return state-1
}
default: return state;
}
};
Thanks in advance