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';
import { processError } from './utils/error';

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

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

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