Skip to content

Instantly share code, notes, and snippets.

@adelowo
Created March 17, 2020 20:55
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/a540f034ea69f2e24c2e23020cd32d71 to your computer and use it in GitHub Desktop.
Save adelowo/a540f034ea69f2e24c2e23020cd32d71 to your computer and use it in GitHub Desktop.
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