working typescript version

This commit is contained in:
erik-sn committed 2020-10-07 12:19:55 -04:00
1 parent 581d6011e0
commit cff746aa38
119 files changed
+247 -189

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import React, { useState } from "react";
import { ContextMenu } from "../components/ContextMenu";
export const MapStringOptions = (current, onClick) => (string) => {
return {
selected: current === string,
label: string,
key: string,
onClick: () => onClick(string),
};
};
export const useContextMenu = (_options = []) => {
const [open, setOpen] = useState();
const [options, setOptions] = useState(_options);
const onClose = () => setOpen(false);
const onOpen = (opts) => {
setOptions(opts);
setOpen(true);
};
return [
onOpen,
onClose,
() => <ContextMenu open={open} onClose={onClose} options={options} />,
open,
];
};