Skip to content

Instantly share code, notes, and snippets.

@philipshen
Last active November 4, 2019 05:56
Show Gist options
  • Select an option

  • Save philipshen/06d26418fabdcbb30d7b88aaff6216d5 to your computer and use it in GitHub Desktop.

Select an option

Save philipshen/06d26418fabdcbb30d7b88aaff6216d5 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import { ActivityIndicator, View } from 'react-native'
import { NavigationAction, NavigationScreenProp } from 'react-navigation'
interface Props {
navigation: NavigationScreenProp<NavigationAction, any>
}
export default class AuthLoadingScreen extends Component<Props, {}> {
constructor(props) {
super(props)
this.verifyAuthenticationAndNavigate()
}
render() {
return (
<View style={{flex: 1, justifyContent: "center", alignItems: "center"}}>
<ActivityIndicator />
</View>
)
}
async verifyAuthenticationAndNavigate() {
const isAuthenticated = await firebase.auth().currentUser().isAuthenticated
this.props.navigation.navigate(isAuthenticated ? 'Main' : 'Auth')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment