Redux - Handle an Action in the Store

Tell us what’s happening:

Sure the code passed I get it the code passed but i want to understand how the reducer is accessing an arrow function that has been called after it cause that makes no sense to me

Your code so far

const defaultState = {
  login: false
};

const reducer = (state = defaultState, action) => {
  // Change code below this line
  if(action.type ==='LOGIN'){
    return {
      login: true
    }
  }
  else{
    return state;
  }
  // Change code above this line
};

const store = Redux.createStore(reducer);

const loginAction = ()=> {
  return {
    type: 'LOGIN'
  }
};

Your browser information:

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

Challenge Information:

Redux - Handle an Action in the Store

Hey to break this down I console logged the store variable:
console.log(store)

result:
{ dispatch: [Function: a],
subscribe: [Function: c],
getState: [Function: o],
replaceReducer: [Function: replaceReducer] }

I believe in this case the function is being used as an argument. I hope this helps.

1 Like

Done it again . Thanks man

1 Like