React context menu
npm install holee-contextmenu!React !Typescript    

``sh
$ yarn add holee-contextmenu
$ npm i holee-contextmenu
`
High customization and intuition.
1. Create a useref.
`javascript`
const outerRef = useRef < HTMLDivElement > null;
2. Designate as ref to the div tag you want to apply the context menu to.
`javascript`
3. Import the menu and create a menu above the div tag.
`javascript`
import { ContextMenu } from 'holee-contextmenu';
`javascript`
4. A menu list of contextmenu can be created by passing the li tag as children in the menu. (A data-option must be specified.)
`javascript`
5. menuOnClickHandler defines an onclick function that is executed when the list is clicked.
`javascript`
const menuOnClickHandler = (e: React.MouseEvent | React.KeyboardEvent
const eventTarget = e.target as HTMLUListElement;
if (eventTarget) {
setOption(() => eventTarget.dataset.option);
}
};
6. Below is the final code, please refer to the example code for details.
`javascript
import React, { useRef, useState } from 'react';
import { ContextMenu } from 'holee-contextmenu';
import './App.css';
function App() {
const outerRef = useRef
const [option, setOption] = useState
const menuOnClickHandler = (e: React.MouseEvent | React.KeyboardEvent
const eventTarget = e.target as HTMLUListElement;
if (eventTarget) {
setOption(() => eventTarget.dataset.option);
}
};
return (
⬇️ Click right mouse inside the red box ⬇️
eventTarget.dataset.option: {option}
export default App;
`
Style can be specified through className:

`css`
.ul-class-name li {
padding: 10px;
color: blue;
}
`js``