mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
* 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
29 lines
574 B
JavaScript
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>
|
|
);
|
|
}
|