Saturday, April 9, 2022

ReactJS Part 4 : Events

All the HTML Controls events are available to React components as props. The event names should have on prefix followed by event name which should be initially capital.

function EventHandling() {
    
    function helloFunction(){
        alert('Hello function')
    }

    const helloArrowSyntax = () => {alert('Hello')}
    return (
    <div>
        <div><button onClick={() => {alert('Hello inline')}}>Hello inline</button></div>
        <div><button onClick={helloFunction}>Hello function</button></div>
        <div><button onClick={helloArrowSyntax}>Hello Arrow Syntax</button></div>
    </div>
  )
}
export default EventHandling



No comments:

Post a Comment