-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom hooks for clicked value implementing
- Loading branch information
1 parent
9edfe1c
commit 17874fd
Showing
8 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { useKeyClickedMethod } from "./useKeyClickedMethod"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { validValues } from "constants/index" | ||
import { useDispatch } from "react-redux" | ||
import { addClickedKeyValue, capsClickHandler, deleteValue, shiftClickHandler } from "store/reducers" | ||
|
||
interface IKeyClickedHook { | ||
subName?: string | null; | ||
name: string; | ||
capsClicked: boolean; | ||
shiftClicked: boolean; | ||
id: string | ||
} | ||
|
||
export const useKeyClickedMethod = ({ id, subName, name, capsClicked, shiftClicked }: IKeyClickedHook) => { | ||
const dispatch = useDispatch(); | ||
|
||
if (validValues.includes(name)) | ||
return dispatch(addClickedKeyValue({ subName, name, capsClicked, shiftClicked })) | ||
if (id === "delete") | ||
return dispatch(deleteValue()) | ||
if (id === "caps-lock") | ||
return dispatch(capsClickHandler()) | ||
if (id === "shift1" || id === "shift2") | ||
return dispatch(shiftClickHandler()) | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters