1

When a user logs out, I want to reset the entire store to it's initial state. I want to do this because I don't want to store any items in memory after they lost the authentication context.

I think this makes the most sense to be implemented as a middleware, so I started as follows

import { LOGOUT } from 'app/actions/auth';

export default function authMiddleware(store) {
  return action => next => {
    if (action.type === LOGOUT) {
      // ???
    }
    next();
  }
}

Specifically, I am having a hard time finding the initial state of the store on the initial instantiation of the application.

Is there a standard way to do this in redux?

corvid
  • 10,733
  • 11
  • 61
  • 130

1 Answers1

1

You can set that to the initial state by declaring a variable as

const initialState = {}; 

And then if the case matches you can return the initialState

Mohhamad Hasham
  • 1,750
  • 1
  • 15
  • 18