fkhadra / fkhadra/react-contexify

Dynamically generate Items for Menu

Open
#200 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
132
PR merge metrics
No merged PRs in 30d

Description

**Do you want to request a *feature* or report a *bug*?**
This *may* be a feature request, or I may simply be missing something.
**What is the current behavior?**
Currently, you have to explicitly define the specific Items to render as JSX components. I'm attempting to get the passed props in a component so I can render a dynamic list.

To clarify, I am trying to use this in MySeparateComponent:
```jsx
const { show } = useContextMenu({
id: 'my-separate-component'
});

//...

const onContextClick = (ev) => {
show(ev, {
items: [itemA, itemB, itemC,]
})
}
```

And then I want to access the `items` array in the context menu to generate the list of Items:
```jsx
function MyCustomContextMenu(props) {

const handleItemClick = (itemClicked) => {
//... (Do something with the item that was passed from props)
}

return (

{props.items.map(( item, index ) => handleItemClick(item)} key={index}>{item.name})}

}
```

Am I missing something? Or is this outside the scope of this library?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.