{"size": 522, "ext": "js", "max_stars_repo_path": "web/src/components/nav/MultiRoute.js", "max_stars_repo_name": "eschmier/directory", "max_stars_repo_stars_event_min_datetime": "2021-05-27T00:43:05.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T05:07:52.000Z", "max_issues_repo_path": "web/src/components/nav/MultiRoute.js", "max_issues_repo_name": "eschmier/directory", "max_issues_repo_issues_event_min_datetime": "2021-05-14T17:38:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T20:16:36.000Z", "max_forks_repo_path": "web/src/components/nav/MultiRoute.js", "max_forks_repo_name": "eschmier/directory", "max_forks_repo_forks_event_min_datetime": "2021-06-01T16:49:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-25T10:10:57.000Z"}
{"max_stars_count": 2, "max_issues_count": 247, "max_forks_count": 4, "avg_line_length": 24.8571428571, "max_line_length": 75, "alphanum_fraction": 0.6647509579}
import { useEffect, useState } from 'react';

const MultiRoute = ({ paths, children }) => {
  const [currentPath, setCurrentPath] = useState(window.location.pathname);

  useEffect(() => {
    const onLocationChange = () => {
      setCurrentPath(window.location.pathname);
    }

    window.addEventListener('popstate', onLocationChange);

    return () => {
      window.removeEventListener('popstate', onLocationChange);
    }
  }, []);

  return paths.has(currentPath) ? children : null;
};

export default MultiRoute;