Skip to content

Instantly share code, notes, and snippets.

@lazorfuzz
Last active December 13, 2018 13:18
Show Gist options
  • Save lazorfuzz/9eed8f65eba3c7c8ad4cd3e5df5f3f24 to your computer and use it in GitHub Desktop.
Save lazorfuzz/9eed8f65eba3c7c8ad4cd3e5df5f3f24 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import './App.css';
import ChatBox from './ChatBox';
class App extends Component {
constructor(props) {
super(props);
this.state = {
chatLog: []
}
}
addChat = (name, message, alert = false) => {
this.setState({ chatLog: this.state.chatLog.concat({
name,
message: `${message}`,
timestamp: `${Date.now()}`,
alert
})});
}
render() {
const { chatLog } = this.state;
return (
<div className="App">
<ChatBox
chatLog={chatLog}
onSend={(msg) => msg && this.addChat('Me', msg)}
/>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment