Skip to content

Instantly share code, notes, and snippets.

@shawn-kb
Created November 14, 2017 17:06
Show Gist options
  • Select an option

  • Save shawn-kb/95cf2a445dae81d488eb37e5bf8cb9b2 to your computer and use it in GitHub Desktop.

Select an option

Save shawn-kb/95cf2a445dae81d488eb37e5bf8cb9b2 to your computer and use it in GitHub Desktop.
cannot seem to inject a store
import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font } from 'expo';
import { Ionicons } from '@expo/vector-icons';
import {NavigationActions} from 'react-navigation'
import RootNavigation from './navigation/RootNavigation';
var DevicePersistantStore = require('react-native-simple-store');
// Mobx state stores
import { inject, observer } from 'mobx-react';
import { observable, action } from "mobx";
import { Provider } from "mobx-react/native";
import SystemStore from "./stores/SystemStore";
@inject("SystemStore")
export default class App extends React.Component {
constructor(props: any) {
super(props);
}
state = {
isLoadingComplete: false,
};
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
} else {
return (
<Provider systemStore={SystemStore} >
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
{Platform.OS === 'android' &&
<View style={styles.statusBarUnderlay} />}
<RootNavigation />
</View>
</Provider>
);
}
}
componentDidMount(){
}
componentWillMount(){
}
_loadResourcesAsync = async () => {
console.log(this.props.systemStore);
return Promise.all([
Font.loadAsync([
// This is the font that we are using for our tab bar
Ionicons.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
{ 'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf') },
]),
//DevicePersistantStore.delete("pivotracStore");
DevicePersistantStore.get('pivotracStore').then((pivotracStore) => {
if (pivotracStore){
login = pivotracStore.login;
password = pivotracStore.password;
this.setState({login: login});
this.setState({password: password});
this.setState({loggedIn: true});
}else{
login = null;
this.setState({loggedIn: true});
}
}).then(() => {
if (login !== null) {
this.setState({login: login});
this.setState({password: password});
this.setState({firstRoute: { name: 'SummaryPage' }})
this._rerouteToSummary();
}else{
//this._rerouteToLogin();
message = "should reroute to login";
}
}),
Asset.loadAsync([
require('./assets/images/robot-dev.png'),
require('./assets/images/robot-prod.png'),
]),
]);
};
_handleLoadingError = error => {
console.warn(error);
};
_handleFinishLoading = () => {
this.setState({ isLoadingComplete: true });
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
statusBarUnderlay: {
height: 24,
backgroundColor: 'rgba(0,0,0,0.2)',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment