Skip to content

Instantly share code, notes, and snippets.

@diego3g
Created September 11, 2017 18:18
Show Gist options
  • Save diego3g/efd436d56c8bbe043ea8a06b5ac5672a to your computer and use it in GitHub Desktop.
Save diego3g/efd436d56c8bbe043ea8a06b5ac5672a to your computer and use it in GitHub Desktop.
// src/index.js
import React from 'react';
import { View } from 'react-native';
import { isSignedIn } from "./services/auth";
import { createRootNavigator, SignedOutRoutes, SignedInRoutes } from './routes';
export default class App extends React.Component {
state = {
signed: false,
signLoaded: false,
};
componentWillMount() {
isSignedIn()
.then(res => this.setState({ signed: res, signLoaded: true }))
.catch(err => alert("Erro"));
}
render() {
const { signLoaded, signed } = this.state;
if (!signLoaded) {
return null;
}
const Layout = createRootNavigator(signed);
return <Layout />;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment