mirror of
https://github.com/cupcakearmy/unpixel.git
synced 2025-12-13 01:05:04 +00:00
cleanup
This commit is contained in:
@@ -7,15 +7,17 @@ import { render } from 'react-dom'
|
||||
// @ts-ignore
|
||||
import chime from 'url:../assets/chime.mp3'
|
||||
|
||||
const useKeyPress = (handler) => {
|
||||
const handlerRef = useRef<(e: KeyboardEvent) => void>()
|
||||
const useKeyPress = (handler: (e: KeyboardEvent) => void) => {
|
||||
const handlerRef = useRef<typeof handler>()
|
||||
|
||||
useEffect(() => {
|
||||
handlerRef.current = handler
|
||||
}, [handler])
|
||||
|
||||
useEffect(() => {
|
||||
const fn = (event) => handlerRef.current(event)
|
||||
const fn = (event: KeyboardEvent) => {
|
||||
if (handlerRef.current) handlerRef.current(event)
|
||||
}
|
||||
window.addEventListener('keydown', fn)
|
||||
return () => {
|
||||
window.removeEventListener('keydown', fn)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* @import 'hiq/dist/hiq.css'; */
|
||||
@import 'spectre.css/dist/spectre.min.css';
|
||||
@import 'tachyons/css/tachyons.min.css';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import React from 'react'
|
||||
|
||||
import Link from './ExternalLink'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user