Skip to content

Instantly share code, notes, and snippets.

@adelowo
Created April 16, 2020 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adelowo/0be913c2bbaf0754f0c945979fbe8048 to your computer and use it in GitHub Desktop.
Save adelowo/0be913c2bbaf0754f0c945979fbe8048 to your computer and use it in GitHub Desktop.
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