Commit dea93e4c authored by Alexander Kotov's avatar Alexander Kotov

add message form component

parent c277a2ed
......@@ -3,6 +3,7 @@ import './App.css';
import Header from './components/Header'
import Messages from './components/Messages'
import MessageForm from './components/MessageForm';
class App extends Component {
user = {
......@@ -24,18 +25,17 @@ class App extends Component {
}
]
sendMessage = (message) => {
console.log('[APP]', message)
}
render() {
return (
<div id="chat">
<Header user={this.user} />
<Messages messages={this.messages} />
<form id="message-form" autocomplete="off">
<input type="text" name="message" />
<button type="submit">
Send
</button>
</form>
<MessageForm onSubmit={this.sendMessage} />
</div>
);
}
......
import React, { Component } from 'react'
class MessageForm extends Component {
onSubmitHandler = (event) => {
event.preventDefault()
console.log('[MessageForm]', 'onSubmitHandler')
this.props.onSubmit({
body: 'Let us ...'
})
}
render() {
return (
<form
id="message-form"
onSubmit={this.onSubmitHandler}
autoComplete="off">
<input type="text" name="message" />
<button type="submit">
Send
</button>
</form>
)
}
}
export default MessageForm
\ No newline at end of file
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