Last active
December 13, 2018 13:18
-
-
Save lazorfuzz/9eed8f65eba3c7c8ad4cd3e5df5f3f24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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