Event Handling in ReactJs

 Event Handling in ReactJs 


Source code:-

App.js


import React, { useState } from "react";

const App = ()=>{
  const purple = '#8e44ad';
  const [bgsetbg] = useState(purple);
  const [clicksetClick] = useState("Click Me");
  const btnClick =()=>{
    setClick("Auch");
    setbg('#d2dbdd');
  }
  const dbtn = ()=>{
    setClick("this is double click");
    setbg('yellow');
  }

  return(
    <><div style={{backgroundColorbg}}>
        <button onDoubleClick={dbtn} onClick={btnClick}>{click}</button>
      </div>
    </>
  );
}

export default App;

index.css

*{
  box-sizingborder-box;
  padding0;
  margin0;
  background-color#d2dbdd;
}

div{
  width100%;
  height100vh;
  displayflex;
  flex-directioncolumn;
  justify-contentcenter;
  align-itemscenter;
}



button{
  padding15px 20px;
  background#9b59b6;
  colorwhite;
  border2px solid #ecf0f1;
  text-transformuppercase;
  cursorpointer;
  border-radius20px;
}