Commit 76decd21 authored by Alexander Kotov's avatar Alexander Kotov

add new message

parent dea93e4c
......@@ -6,35 +6,43 @@ import Messages from './components/Messages'
import MessageForm from './components/MessageForm';
class App extends Component {
user = {
name: 'Alexander Kotov'
}
messages = [
{
body: 'Welcome',
author: 'Alexander Kotov'
},
{
body: 'Hi',
author: 'Dima'
state = {
user: {
name: 'Alexander Kotov'
},
{
body: 'Cool!',
author: 'Taras'
}
]
messages: [
{
body: 'Welcome',
author: 'Alexander Kotov'
},
{
body: 'Hi',
author: 'Dima'
},
{
body: 'Cool!',
author: 'Taras'
}
]
}
sendMessage = (message) => {
console.log('[APP]', message)
this.setState({
messages: [
...this.state.messages,
{
...message,
author: this.state.user.name
}
]
})
}
render() {
return (
<div id="chat">
<Header user={this.user} />
<Messages messages={this.messages} />
<Header user={this.state.user} />
<Messages messages={this.state.messages} />
<MessageForm onSubmit={this.sendMessage} />
</div>
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment