-
-
Save adelowo/0be913c2bbaf0754f0c945979fbe8048 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
import React, {Component} from 'react'; | |
import {View, SafeAreaView} from 'react-native'; | |
import Login from './Login'; | |
import Chat from './Chat'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isAuthenticated: false, | |
}; | |
this.chatClient = null; | |
} | |
onLoginSuccessCallback = chatClient => { | |
this.chatClient = chatClient; | |
this.setState({ | |
isAuthenticated: true, | |
}); | |
}; | |
render() { | |
return ( | |
<SafeAreaView style={{flex: 1}}> | |
<View style={{flex: 1}}> | |
{this.state.isAuthenticated && this.chatClient !== null ? ( | |
<Chat chatClient={this.chatClient} /> | |
) : ( | |
<Login cb={this.onLoginSuccessCallback} /> | |
)} | |
</View> | |
</SafeAreaView> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment