Function

  • Step

    1. define a function inside the class

    
                 const handleClick = () => {
                  console.log('Click happened');
                };
    
              

    2. function call

    
    
                'use client'
                import React from 'react';
    
                export default function Home() {              
    
                  const handleClick = () => {
                    console.log('Click happened');
                  };
    
                  
                  return (
                    <div className='App'>
                      <h1>Hello React.</h1>
                      <h2>Start editing to see some magic happen! </h2>
                      <button onClick={handleClick}>Click Me</button>
                    </div>
                  );
                  
                }