Did I break the Redux reducer's key principle of read-only in this case

Tell us what’s happening:


In this challenge my code passed all tests, however I have some doubts about whether I violated the rule of immutability in this case since I used state = { login: true }
in the if-statement? The problem’s solution does it without the return statement and reassigning the values of the state object.

Your code so far

const defaultState = {
login: false

const reducer = (state = defaultState, action) => {
// change code below this line
if (action.type == 'LOGIN') {
  return state = { 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/80.0.3987.132 Safari/537.36.

Challenge: Handle an Action in the Store

Link to the challenge: