{"size": 868, "ext": "js", "max_stars_repo_path": "redbubble/node_modules/@redbubble/design-system/react/Dropdown/DropdownLink.js", "max_stars_repo_name": "vunamhung/codebases", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "redbubble/node_modules/@redbubble/design-system/react/Dropdown/DropdownLink.js", "max_issues_repo_name": "vunamhung/codebases", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "redbubble/node_modules/@redbubble/design-system/react/Dropdown/DropdownLink.js", "max_forks_repo_name": "vunamhung/codebases", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.5294117647, "max_line_length": 79, "alphanum_fraction": 0.668202765}
import React from 'react';
import PropTypes from 'prop-types';
import { MenuLink as ReachMenuLink } from '@reach/menu-button';
import { MenuLink } from '../Menu';
import useTracking, { trackingShape, EVENT_CLICK } from '../hooks/useTracking';
import wrapForReachUI from './wrapForReachUI';

const events = { EVENT_CLICK };

const PreparedMenuLink = wrapForReachUI(MenuLink);

const DropdownLink = ({ onSelect, tracking, ...props }) => {
  const { track } = useTracking(tracking, 'DropdownLink', events);

  return (
    <ReachMenuLink
      as={PreparedMenuLink}
      {...props}
      onSelect={(...args) => {
        track(EVENT_CLICK);
        if (typeof onSelect === 'function') onSelect(...args);
      }}
    />
  );
};

DropdownLink.propTypes = {
  children: PropTypes.node,
  href: PropTypes.string,
  tracking: trackingShape,
};

export default DropdownLink;
