import React, { Component } from 'react'; import firebase from 'firebase' import thunk from 'redux-thunk'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import { createDrawerNavigator } from '@react-navigation/drawer'; import { Provider } from 'react-redux'; import { createStore, applyMiddleware } from 'redux'; import AvailabilityScreen from './screens/AvailabilityScreen'; import MailScreen from './screens/MailScreen'; import RegisterScreen from './screens/RegisterScreen'; import LoginScreen from './screens/LoginScreen'; import HomeScreen from './screens/HomeScreen'; import Loading from './components/Loading'; import { firebaseConfig } from './config/firebaseConfig'; import rootReducer from './redux/reducers' if (firebase.apps.length === 0) { firebase.initializeApp(firebaseConfig) } const Stack = createStackNavigator(); const Drawer = createDrawerNavigator(); const store = createStore(rootReducer, applyMiddleware(thunk)); export default class App extends Component { constructor(props){ super(props); this.state = { loaded: false, } } componentDidMount(){ firebase.auth().onAuthStateChanged((user) => { if (!user){ this.setState({ loggedIn: false, loaded: true, }) } else{ this.setState({ loggedIn: true, loaded: true, }) } }); } createHomeStack = () => render() { const { loggedIn, loaded } = this.state if(!loaded){ return( ); } if(!loggedIn){ return ( ); } return( ); } }