Skip to content

Commit

Permalink
Use items instead
Browse files Browse the repository at this point in the history
  • Loading branch information
minosss committed Aug 23, 2023
1 parent c689145 commit 555bfd2
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/DropdownMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Menu, { MenuItem } from 'rc-menu';
import Menu from 'rc-menu';
import * as React from 'react';
import type { DataDrivenOptionProps } from './Mentions';
import MentionsContext from './MentionsContext';
Expand Down Expand Up @@ -34,30 +34,23 @@ function DropdownMenu(props: DropdownMenuProps) {
}}
onFocus={onFocus}
onBlur={onBlur}
>
{options.length > 0 ? (
options.map((option, index) => {
const { key, disabled, className, style, label } = option;
return (
<MenuItem
key={key}
disabled={disabled}
className={className}
style={style}
onMouseEnter={() => {
setActiveIndex(index);
}}
>
{label}
</MenuItem>
);
})
) : (
<MenuItem key="not-found" disabled>
{notFoundContent}
</MenuItem>
)}
</Menu>
items={
options.length > 0
? options.map(
({ key, disabled, className, label, style }, index) => ({
key,
disabled,
className,
style,
label,
onMouseEnter: () => {
setActiveIndex(index);
},
}),
)
: [{ key: 'not-found', disabled: true, label: notFoundContent }]
}
/>
);
}

Expand Down

0 comments on commit 555bfd2

Please sign in to comment.