Event : stopPropagation

 


import "./style.css";

export default function () {

function Red(event) {
alert("Red");
}
function Blue(event) {
event.stopPropagation();
console.log(event.type);
alert("Blue");
}

return <>
<div onClick={Red} className={"red-box"}>
<div onClick={Blue} className={"blue-box"}>

</div>
</div>
</>
}


.red-box{
height: 400px;
width: 400px;
border: solid 1px;
background: red;

display: flex;
justify-content: center;
align-items: center;
}

.blue-box{
height: 200px;
width: 200px;
border: solid 1px;
background: blue;
}



Comments

Popular posts from this blog

App 1st User Define Component

Example 1

Rabiit