Created
September 11, 2017 18:18
-
-
Save diego3g/efd436d56c8bbe043ea8a06b5ac5672a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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