Redux - Dispatch an Action Event

Tell us what’s happening:
I am trying to understand working on Redux and here in the screenshot, I tried to console.log before and after dispatching, but I do not see any changes in the object in the log. Should there be any changes? Am I missing something?

Your code so far

const store = Redux.createStore(
  (state = {login: false}) => state
);

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

console.log(store,"before")
// Dispatch the action here:
store.dispatch(loginAction())
console.log(store,"after")

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Challenge: Redux - Dispatch an Action Event

Link to the challenge:

First of all, you would want to log out:

store.getState()

But it won’t matter, because you are not doing anything with the state. Your reducer is just returning the state unaltered. In future lessons, you will learn how to use the reducer to create a new version of state. In this lesson, you are just learning how to use an action creator to create an action and dispatch that. Your reducer is receiving that action but we haven’t told it what to do with that action yet - don’t worry, you will.

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