'React-native-async-storage doesn't recognize moment toDate() after killing app

I'm implementing "Add Favorite" and store it those items in async-storage Vs react-redux. It's working fine when after adding and switching from Home Tab to Favorite Tab. But I got the error "date.toDate is not a function" after killing app and go to Favorite Tab.

Any suggestions and solutions? Thank you so much!

Component

      <CardInfo
      key={data.id.toString()}
      promotionToDate={moment(data.expireDate.toDate()).format('lll')}
      />

Action

export const getPromotionsAction = () => async dispatch => {
  dispatch({type: GET_PROMOTION});

  const response = await firebase.firestore().collection('xxxx').get();
  const values = [];
  response.docs.forEach(res => {
    values.push(res.data());
  });
  dispatch({type: GET_PROMOTION, payload: values});
  return values;
};

export const addFavoriteAction = fav => dispatch => {
  dispatch({
    type: ADD_PROMOTION_TO_FAVORITE_LIST,
    payload: fav,
  });
};

Store

// import rootReducer from '../redux';
import thunk from 'redux-thunk';
import PromotionReducer from './reducers';
import {persistStore, persistReducer} from 'redux-persist';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {createStore, combineReducers, applyMiddleware} from 'redux';
import {logger} from 'redux-logger';

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['setPromotionToFavorites'],
};

const rootReducer = combineReducers({
  PromotionReducers: persistReducer(persistConfig, PromotionReducer),
});

export const store = createStore(rootReducer, applyMiddleware(thunk, logger));
export const persistor = persistStore(store);
export type RootStateType = ReturnType<typeof store.getState>;

NOTED I'm using Firestore, Momentjs enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source