1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. import * as React from 'react';
    
  11. import {useContext} from 'react';
    
  12. import {RegistryContext} from './Contexts';
    
  13. 
    
  14. import styles from './ContextMenuItem.css';
    
  15. 
    
  16. import type {RegistryContextType} from './Contexts';
    
  17. 
    
  18. type Props = {
    
  19.   children: React$Node,
    
  20.   onClick: () => void,
    
  21.   title: string,
    
  22. };
    
  23. 
    
  24. export default function ContextMenuItem({
    
  25.   children,
    
  26.   onClick,
    
  27.   title,
    
  28. }: Props): React.Node {
    
  29.   const {hideMenu} = useContext<RegistryContextType>(RegistryContext);
    
  30. 
    
  31.   const handleClick = (event: any) => {
    
  32.     onClick();
    
  33.     hideMenu();
    
  34.   };
    
  35. 
    
  36.   return (
    
  37.     <div
    
  38.       className={styles.ContextMenuItem}
    
  39.       onClick={handleClick}
    
  40.       onTouchEnd={handleClick}>
    
  41.       {children}
    
  42.     </div>
    
  43.   );
    
  44. }