-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add useKeyPress
hooks and shortcut in ImportModal
#62
Conversation
src/containers/ImportModal/index.tsx
Outdated
@@ -7,6 +7,7 @@ import { ConfigActionType } from "src/reducer/reducer"; | |||
import { Modal, ModalProps } from "src/components/Modal"; | |||
import { Button } from "src/components/Button"; | |||
import { AiOutlineUpload } from "react-icons/ai"; | |||
import useKeyPress from "../../hooks/useKeyPress"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change import to absolute path
src/containers/ImportModal/index.tsx
Outdated
const handleEspacePress = useKeyPress("Escape"); | ||
const handleEnterKeyPress = useKeyPress("Enter"); | ||
React.useEffect(() => { | ||
if (handleEspacePress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduce condition to single line if (...) doSomething()
src/hooks/useKeyPress.tsx
Outdated
const [keyPressed, setKeyPressed] = React.useState(false); | ||
|
||
function downHandler({ key }) { | ||
if (key === targetKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduce conditions to one line
src/hooks/useKeyPress.tsx
Outdated
} | ||
} | ||
const upHandler = ({ key }) => { | ||
if (key === targetKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduce conditions to one line
Please add key shortcuts to |
No description provided.