Event Handling:
- React events are named using camelCase, rather than lowercase.
- In this Event handling use the Arrow function like,(cilck event =() =>{})
- In this Event handling have many events
Now, I used onMouseOver Event:
import
React from 'react';
import
ReactDOM from 'react-dom';
class
Eventbind extends React.Component{
constructor(){
super();
this.state={value:"welcome"}
}
clickEvent = () =>
{
this.setState({value:"Thank
you"})
}
render()
{
return
<div>
<h1>{this.state.value}</h1>
<br></br>
<button
onMouseOver={this.clickEvent}>changevalue</button>
</div>
}
}
ReactDOM.render(<Eventbind/>,document.getElementById('root'));
when Click the changevalue button "Welcome" change into "Thank you".
Comments