I want to hide child div when clicked outside the child div. Toggle button should also work in this case.
import React, { useState } from "react";
export default function Toggle() {
  const [view, setView] = useState(false);
  return (
    <div style={{ height: "100vh", backgroundColor: "lightblue" }}>
     
      <button onClick={() => setView(!view)}> show/hide </button>
    
      <div 
        style={{
          display: `${view ? "block" : "none"}`,
          height: "20vh",
          width: "10vw",
          backgroundColor: "lightcoral",
        }}
      >
        Child Div
      </div>
      </div>
  );
} 
    