const localStoredReducer = (reducer, localStorageName) =>
  (state, action) => {

    if(!state) {
      const key = localStorage.getItem(localStorageName);
      if(key) {
       return JSON.parse(key);
      } else {
        let newState = reducer(state,action);
        localStorage.setItem(localStorageName, JSON.stringify(newState))
        return newState;
      }

    }
   
   

  }
combineReducers({cart: localStoredReducer(cartReducer, 'cart')})  



