Skip to content
This repository was archived by the owner on Jul 22, 2026. It is now read-only.

Commit b679772

Browse files
auth state check done
1 parent 3f645ca commit b679772

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

screens/Initial.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@ import { AppLoading } from 'expo'
33
import { Asset } from 'expo-asset'
44
import * as Font from 'expo-font'
55
import * as Icon from '@expo/vector-icons'
6+
import { withFirebaseHOC } from '../config/Firebase'
67

7-
export default class Initial extends Component {
8+
class Initial extends Component {
89
state = {
910
isAssetsLoadingComplete: false
1011
}
1112

1213
componentDidMount = async () => {
13-
this.loadLocalAsync()
14+
try {
15+
// previously
16+
this.loadLocalAsync()
1417

15-
// TODO: add auth check here with firebase
16-
this.props.navigation.navigate('Auth')
18+
await this.props.firebase.checkUserAuth(user => {
19+
if (user) {
20+
// if the user has previously logged in
21+
this.props.navigation.navigate('App')
22+
} else {
23+
// if the user has previously signed out from the app
24+
this.props.navigation.navigate('Auth')
25+
}
26+
})
27+
} catch (error) {
28+
console.log(error)
29+
}
1730
}
1831

1932
loadLocalAsync = async () => {
@@ -48,3 +61,5 @@ export default class Initial extends Component {
4861
)
4962
}
5063
}
64+
65+
export default withFirebaseHOC(Initial)

0 commit comments

Comments
 (0)