Reputation: 639
I'm in a weird state where I'm trying to bug track an issue and output to the console log and I'm not even getting that at this point.
The post is asking for more details but there aren't any. I'm just trying to figure out basic bug tracking at this point.
import React, { Component } from 'react';
import { View } from 'react-native';
import firebase from 'firebase';
import { Header, Button, CardSection, Spinner } from './components/common/';
import LoginForm from './components/LoginForm';
class App extends Component {
state = { loggedIn: null };
componentWillMount() {
firebase.initializeApp({
apiKey: 'xxxxxxxxxxxx',
authDomain: 'xxxxxxxxx.firebaseapp.com',
databaseURL: 'https://xxxxxxx.firebaseio.com',
projectId: 'xxxxx',
storageBucket: 'xxxxx.appspot.com',
messagingSenderId: 'xxxxxxxxx'
});
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.setState({ loggedIn: true });
} else {
this.setState({ loggedIn: false });
}
});
}
renderContent() {
if (this.state.loggedIn) {
switch (this.state.loggedIn) {
case true:
return console.log('true');
// return (
// <CardSection>
// <Button onPress={() => firebase.auth().signOut()}>
// Log Out
// </Button>
// </CardSection>
// );
case false:
return console.log('false');
// return <LoginForm />;
default:
return console.log('default');
// return <Spinner size="large" />;
}
}
}
render() {
return (
<View>
<Header headerText="Authentication" />
{this.renderContent()}
</View>
);
}
}
export default App;
Upvotes: 0
Views: 556
Reputation: 639
I just figured it out. It's the IF statement that's right after the renderContent call; it's not supposed to be there. Sorry to bother.
Upvotes: 0
Reputation: 10709
The problem is that this.state.loggedIn
is null
the whole time, therefore your code enters never the switch statements. Accordingly you don't get an output.
Upvotes: 1