scrimba
Building a chat app with React and Chatkit
Broadcasting messages
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Broadcasting messages
Expand for more info
components
SendMessageForm.js
run
preview
console
import React from 'react'

class SendMessageForm extends React.Component {

constructor() {
super()
this.state = {
message: ''
}
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}

handleChange(e) {
this.setState({
message: e.target.value
})
}

handleSubmit(e) {
e.preventDefault()
console.log(this.state.message)
/** send off the message */
}

render() {
return (
<form
onSubmit={this.handleSubmit}
className="send-message-form">
<input
onChange={this.handleChange}
value={this.state.message}
placeholder="Type your message and hit ENTER"
type="text" />
</form>
)
}
}

export default SendMessageForm
Console
index.html
-5:12