Redux: dispatch methode

Hello,
Dispatch an Action Event

In this lesson we learn dispatch() methode to send the action to the store. But in the next exercises we don’t use dispatch() anymore. In the next one for exemple, here is the code:
Handle an Action in the Store

const defaultState = {   // state de départ
  login: false
};

const reducer = (state = defaultState, action) => {  // le reducer qui est chargé de modifier le state, on lui transmet donc le state de départ.
  // 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);  // la création du store

const loginAction = () => {  // l'action a transmettre
  return {
    type: 'LOGIN'
  }
};

Why loginAction is not send by dispatch ?
I would like understand why dispatch is not used.

Because now they’re discussing actions and reducers. They want you to focus on that. The test will dispatch behind the scenes to confirm what you’ve done. If they try to fit everything on the screen it will be distracting. They’re trying to build this piece by piece. They’re having you measure out the ingredients one by one - so correct, you can’t taste the cake yet, you’re not there yet. Just try to focus on the piece of the puzzle in front of you and try to understnd that. There are a few different aspect to Redux that are beng explained one at a time, in isolation. They’ll be put together later on.

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