Redux - Write a Counter with Redux

I don’t understand why my incAction is working and my decAction is not .

  **Your code so far**
const INCREMENT = 'INCREMENT'; // Define a constant for increment action types
const DECREMENT = 'DECREMENT'; // Define a constant for decrement action types
const defaultState = 0;

const counterReducer = (state = defaultState, action) => {
switch (action.type) {
  case INCREMENT:
    return state +1;
  case DECREMENT:
    return state +1;
  default:
    return state;
}
}; // Define the counter reducer which will increment or decrement the state based on the action it receives

const incAction = () => {
return {
  type: INCREMENT
};
} // Define an action creator for incrementing

const decAction = () => {
return {
  type: DECREMENT
};
} // Define an action creator for decrementing

const store = Redux.createStore(
counterReducer,
Redux.applyMiddleware(ReduxThunk.default)
); // Define the Redux store here, passing in your reducers
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Redux - Write a Counter with Redux

Link to the challenge:

Do we agree what the word “decrement” means? :wink:

I shouldn’t tease, I make cut and paste mistakes all the time.

Thx. I see that now. Sorry to bother.

No bother, that’s why we’re here. Sometimes you need another set of eyes.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.