refactor(useKeyPress): check if key code is string

This commit is contained in:
moklick
2022-01-03 17:54:26 +01:00
parent 7a7ddbedb6
commit f01e239947
2 changed files with 1 additions and 3 deletions
-2
View File
@@ -51,8 +51,6 @@ const InteractionFlow = () => {
const [captureZoomScroll, setCaptureZoomScroll] = useState<boolean>(false);
const [captureElementClick, setCaptureElementClick] = useState<boolean>(false);
console.log(11, captureElementClick);
return (
<ReactFlow
nodes={nodes}
+1 -1
View File
@@ -30,7 +30,7 @@ export default (keyCode: KeyCode | null = null, options: UseKeyPressOptions = {
const [keyCodes, keysToWatch] = useMemo<[Array<Keys>, Keys]>(() => {
if (keyCode !== null) {
const keyCodeArr = Array.isArray(keyCode) ? keyCode : [keyCode];
const keys = keyCodeArr.map((kc) => kc.split('+'));
const keys = keyCodeArr.filter((kc) => typeof kc === 'string').map((kc) => kc.split('+'));
const keysFlat = keys.reduce((res: Keys, item) => res.concat(...item), []);
return [keys, keysFlat];