mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 18:25:30 +00:00
Use functional component
This commit is contained in:
parent
d24b86e189
commit
cc18d9336a
1 changed files with 18 additions and 20 deletions
|
|
@ -98,27 +98,25 @@ interface ContextMenuProps {
|
|||
zIndex: number;
|
||||
}
|
||||
|
||||
class ContextMenu extends React.Component<ContextMenuProps> {
|
||||
render() {
|
||||
const {
|
||||
children,
|
||||
offsetTop,
|
||||
offsetLeft,
|
||||
top,
|
||||
bottom,
|
||||
selected,
|
||||
zIndex,
|
||||
} = this.props;
|
||||
return (
|
||||
selected && (
|
||||
<Portal top={offsetTop} left={offsetLeft} zIndex={zIndex}>
|
||||
<ul className={classnames("context-menu", { top, bottom })}>
|
||||
{children}
|
||||
</ul>
|
||||
</Portal>
|
||||
)
|
||||
);
|
||||
function ContextMenu({
|
||||
children,
|
||||
offsetTop,
|
||||
offsetLeft,
|
||||
top,
|
||||
bottom,
|
||||
selected,
|
||||
zIndex,
|
||||
}: ContextMenuProps) {
|
||||
if (!selected) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Portal top={offsetTop} left={offsetLeft} zIndex={zIndex}>
|
||||
<ul className={classnames("context-menu", { top, bottom })}>
|
||||
{children}
|
||||
</ul>
|
||||
</Portal>
|
||||
);
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: AppState) => ({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue