-
-
Save adelowo/a540f034ea69f2e24c2e23020cd32d71 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 "./App.css"; | |
import "bootstrap/dist/css/bootstrap.min.css"; | |
import "stream-chat-react/dist/css/index.css"; | |
import Login from "./Login"; | |
import ChatView from "./ChatView"; | |
import { StreamChat } from "stream-chat"; | |
export default class App extends Component { | |
state = { isAuthenticated: false }; | |
constructor(props) { | |
super(props); | |
this.chatClient = new StreamChat("STREAM_CHAT_API_KEY"); | |
} | |
setUser = (user, token) => { | |
this.chatClient.setUser(user, token); | |
this.setState({ isAuthenticated: true }); | |
}; | |
render() { | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
{this.state.isAuthenticated ? ( | |
<ChatView chatClient={this.chatClient} /> | |
) : ( | |
<Login cb={this.setUser} /> | |
)} | |
</header> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment