0

I want to save current state of Redux store. There are two options: Local Storage or Cookies. I want to save it in to cookies. First, I save curret state to cookie like that:

this.props.cookies.set('cp', store.getState()); 

Then to load saved state in reducer I am using this initial state.

 let initialState = {}
if (cookies.get('cp')) {
    initialState = cookies.get('cp');
} else {
    initialState = {
        user: {
            loggedIn: false,
               },

    }
}

Is this a good or bad way to save state?

Peretz30
  • 1,264
  • 1
  • 11
  • 15
  • What made you choose cookies over local storage? See https://stackoverflow.com/questions/3220660/local-storage-vs-cookies This should help you decide if you've taken the right approach – Christopher Moore Feb 06 '18 at 14:16
  • 1
    @ChristopherMoore thank you for your answer. I choosed cookie because I need IE support. But now I figured out that Local Storage have IE 11 support. Maybe Local storage is really right way... – Peretz30 Feb 06 '18 at 14:27

0 Answers0