Example of ReactJS event handling?

import React, { Component } from 'react'
export class Message extends Component {
constructor(props){
super(props)
this.state={name:"Jahid",message:""}
}
messageHandler=()=>{
this.setState({message:"Thank you"})
}
nameHandler=(event)=>{
this.setState({name:event.target.value})
}
render() {
return (
<div>
Hello {this.state.name} {this.state.message}
<input type="text" onChange={this.nameHandler} />
<button onClick={this.messageHandler}>Message</button>
</div>
)
}
}
export default Message
Comments 0