Files
react/packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenuItem.js
T
Brian VaughnandGitHub 8f25f2637f DevTools context menu (#17608)
* Added rudimentary context menu hook and menu UI

* Added backend support for copying a value at a specific path for the inspected element

* Added backend support for storing a value (at a specified path) as a global variable

* Added special casing to enable copying undefined/unserializable values to the clipboard

* Added copy and store-as-global context menu options to selected element props panel

* Store global variables separately, with auto-incremented name (like browsers do)

* Added tests for new copy and store-as-global backend functions

* Fixed some ownerDocument/contentWindow edge cases

* Refactored context menu to support dynamic options

Used this mechanism to add a conditional menu option for inspecting the current value (if it's a function)

* Renamed "safeSerialize" to "serializeToString" and added inline comment
2019-12-18 12:12:34 -08:00

29 lines
574 B
JavaScript

import React, {useContext} from 'react';
import {RegistryContext} from './Contexts';
import styles from './ContextMenuItem.css';
type Props = {|
children: React$Node,
onClick: Object => void,
title: string,
|};
export default function ContextMenuItem({children, onClick, title}: Props) {
const {hideMenu} = useContext(RegistryContext);
const handleClick = event => {
onClick();
hideMenu();
};
return (
<div
className={styles.ContextMenuItem}
onClick={handleClick}
onTouchEnd={handleClick}>
{children}
</div>
);
}