Disable Contextmenu In Reactjs
first post here so hopefully I can ask this question the most helpful manner possible. I'm pretty new to coding and in trying to push myself decided to attempt to recreate Mineswee
Solution 1:
I know its an old one but heres my solution for this: first, select the element you want to disable the contextMenu for (in this occasion its a div element) and just add this piece to the element:
<div onContextMenu={(e)=> e.preventDefault()}... />
ReactDOM.render(<divonContextMenu={(e)=> e.preventDefault()}>right click me</div>, root)
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/react/16.11.0/umd/react.production.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.11.0/umd/react-dom.production.min.js"></script><divid="root"></div>
right clicking the div above won't trigger the context menu
Post a Comment for "Disable Contextmenu In Reactjs"