import React from 'react';
import { AppRegistry, AsyncStorage } from 'react-native';
import { persistStore, autoRehydrate } from 'redux-persist';

import dva from './utils/dva';
import Router from './router';
import models from './models';
import routerModel from './models/router';

const app = dva({
  initialState: {},
  models: [...models, routerModel],
  extraEnhancers: [autoRehydrate()],
  onError(e) {
    console.log('onError', e);
  },
});

const App = app.start(<Router />);
persistStore(app.getStore(), {
  storage: AsyncStorage,
  blacklist: ['router'],
});

AppRegistry.registerComponent('bolanManagerApp', () => App);
