Created
April 4, 2018 07:36
-
-
Save codegeous/2709aecf50f0adeb2adc3a223ffc6b8b to your computer and use it in GitHub Desktop.
Here is the code that uses react-contexify for displaying context menu in react app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { ContextMenu, Item, Separator, Submenu, ContextMenuProvider } from 'react-contexify'; | |
import 'react-contexify/dist/ReactContexify.min.css'; | |
const ContextMenuItems = props => ( | |
<ContextMenu id='menu_id'> | |
<Item onClick={props.onClick}>Edit</Item> | |
<Separator /> | |
<Submenu label="Set Reminder" arrow={<i className="material-icons"></i>}> | |
<Item onClick={props.onClick}>Me</Item> | |
<Submenu label="Others" arrow={<i className="material-icons"></i>}> | |
<Item onClick={props.onClick}>Family</Item> | |
<Item onClick={props.onClick}>Friends</Item> | |
<Item onClick={props.onClick}>Foodies</Item> | |
<Item onClick={props.onClick}>Jen</Item> | |
<Item onClick={props.onClick}>Margaret</Item> | |
</Submenu> | |
</Submenu> | |
<Separator /> | |
</ContextMenu> | |
); | |
class Message extends Component { | |
onClick = ({ event, ref, data, dataFromProvider }) => console.log('Hello'); | |
render() { | |
const {message} = this.props; | |
return ( | |
<div> | |
<ContextMenuProvider id="menu_id"> | |
<label className="event-content"> | |
This is a context menu | |
</label> | |
</ContextMenuProvider> | |
<ContextMenuItems onClick={this.onClick}/> | |
</div> | |
); | |
} | |
} | |
export default Message; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment