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.error('onError', e); // eslint-disable-line no-console
  },
});

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

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