Interactive Context Menu Component
Context menus are fundamental UI elements across many applications, providing quick access to relevant actions based on user interaction with a specific element. This problem evaluates your ability to build a reusable, accessible context menu component in React, demonstrating core UI development skills including state management, event handling, and basic positioning.
Your goal is to implement a custom context menu that appears when a user right-clicks on a designated target area. Specifically, you need to:
ContextMenu component: This component should be responsible for rendering the menu items and managing its own visibility and position.App component to show the ContextMenu when the onContextMenu event fires on the target-area div.ContextMenu component should accept a list of menu items (each with a label and an action) and render them.alert or console.log).Escape key.action function.Escape key.target-area successfully opens the custom context menu.Escape key while the context menu is open causes it to close.target-area.Constraints
id, label, and action properties, as provided in the starter code.div.Escape to close).contextmenu, click (for outside clicks), and keydown (for Escape).Loading editor...