Skip to content

Instantly share code, notes, and snippets.

@whitneyburton

whitneyburton/hooks-four.js Secret

Last active Jan 7, 2020
Embed
What would you like to do?
const App = () => {
const [open, toggleOpen] = React.useState(true);
const toggleDemo = () => {
if (open) {
toggleOpen(false);
} else {
toggleOpen(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 ${open ? 'wrapper--open' : ''}`}>
<Chat client={chatClient} theme={'commerce dark'}>
<Channel channel={channel}>
<Window>
<ChannelHeader />
{open && (
<MessageList
typingIndicator={TypingIndicator}
Message={MessageCommerce}
/>
)}
<MessageInput Input={MessageInputFlat} />
</Window>
</Channel>
</Chat>
<Button onClick={toggleDemo} open={open} />
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.