{"size": 428, "ext": "js", "max_stars_repo_path": "src/components/outsideClick.js", "max_stars_repo_name": "bono-podo-kakaoent/gatsby-blog", "max_stars_repo_stars_event_min_datetime": "2020-03-13T17:09:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-08T07:11:01.000Z", "max_issues_repo_path": "src/components/outsideClick.js", "max_issues_repo_name": "blueshw/gatsby-blog", "max_issues_repo_issues_event_min_datetime": "2018-10-05T14:56:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-31T05:52:33.000Z", "max_forks_repo_path": "src/components/outsideClick.js", "max_forks_repo_name": "bono-podo-kakaoent/gatsby-blog", "max_forks_repo_forks_event_min_datetime": "2019-10-23T06:16:48.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-01T00:22:22.000Z"}
{"max_stars_count": 3, "max_issues_count": 31, "max_forks_count": 6, "avg_line_length": 20.380952381, "max_line_length": 66, "alphanum_fraction": 0.5630841121}
import React, { useEffect } from 'react';

export default function OutsideClick({ onClick, children }) {
  useEffect(() => {
    function handleClick() {
      onClick();
    }
    window.addEventListener('click', handleClick);
    return () => window.removeEventListener('click', handleClick);
  }, []);
  return (
    <div
      onClick={(e) => {
        e.stopPropagation();
      }}
    >
      {children}
    </div>
  );
}
