@@ -3,18 +3,18 @@ import Sentry from 'sentry-expo';
33import React , { Fragment } from 'react' ;
44import { StatusBar } from 'react-native' ;
55import { SecureStore , AppLoading } from 'expo' ;
6- import { createStore } from 'redux' ;
76import { Provider } from 'react-redux' ;
87import { ApolloProvider } from 'react-apollo' ;
98import { ThemeProvider } from 'styled-components' ;
109import { ActionSheetProvider } from '@expo/react-native-action-sheet' ;
1110import { type ApolloClient } from 'apollo-client' ;
11+ import { initStore } from './reducers/store' ;
1212
13+ import Toasts from './components/Toasts' ;
1314import theme from '../shared/theme' ;
1415import { createClient } from '../shared/graphql' ;
1516import Login from './components/Login' ;
1617import TabBar from './views/TabBar' ;
17- import reducers from './reducers' ;
1818import { authenticate } from './actions/authentication' ;
1919
2020let sentry = Sentry . config (
@@ -24,7 +24,7 @@ let sentry = Sentry.config(
2424// Need to guard this for HMR to work
2525if ( sentry && sentry . install ) sentry . install ( ) ;
2626
27- export const store = createStore ( reducers ) ;
27+ export const store = initStore ( ) ;
2828
2929type State = {
3030 authLoaded : ?boolean ,
@@ -61,7 +61,9 @@ class App extends React.Component<{}, State> {
6161 } ;
6262
6363 listen = ( ) = > {
64- const { authentication } = store . getState ( ) ;
64+ const storeState = store . getState ( ) ;
65+ // $FlowFixMe
66+ const authentication = storeState && storeState . authentication ;
6567 const { token : oldToken } = this . state ;
6668 if ( authentication . token !== oldToken ) {
6769 this . setState ( {
@@ -89,6 +91,7 @@ class App extends React.Component<{}, State> {
8991 < ActionSheetProvider >
9092 < Fragment >
9193 < StatusBar barStyle = { 'default' } />
94+ < Toasts />
9295 { ! token ? < Login /> : < TabBar /> }
9396 </ Fragment >
9497 </ ActionSheetProvider >
0 commit comments