Skip to content

Instantly share code, notes, and snippets.

@whitneyburton
Last active January 7, 2020 22:48
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 whitneyburton/72154fed23f6017bf0cdd852ae3df542 to your computer and use it in GitHub Desktop.
Save whitneyburton/72154fed23f6017bf0cdd852ae3df542 to your computer and use it in GitHub Desktop.
const App = () => {
constructor(props) {
super(props);
this.state = {
open: true,
};
}
const toggleDemo = () => {
if (this.state.open) {
this.setState({ open: false });
} else {
this.setState({ open: true });
}
};
// componentDidMount() {
// console.log('componentDidMount - rendered!');
// channel.sendMessage({
// text: 'Welcome to our customer chat with React Hooks tutorial!',
// });
// };
// componentWillUnmount() {
// console.log(`You have ${channel.state.messages.length} stored in local state. Goodbye!`);
// };
return (
<div className={`wrapper ${this.state.open ? 'wrapper--open' : ''}`}>
<Chat client={chatClient} theme={'commerce dark'}>
<Channel channel={channel}>
<Window>
<ChannelHeader />
{this.state.open && (
<MessageList
typingIndicator={TypingIndicator}
Message={MessageCommerce}
/>
)}
<MessageInput Input={MessageInputFlat} />
</Window>
</Channel>
</Chat>
<Button onClick={this.toggleDemo} open={this.state.open} />
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment