-
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.
* Fix removeEventListener not working * Rename * Bump lint
- Loading branch information
Showing
6 changed files
with
97 additions
and
130 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@buildinams/use-keydown", | ||
"description": "React hook for listening to custom keydown events.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
"author": "Build in Amsterdam <[email protected]> (https://www.buildinamsterdam.com/)", | ||
"main": "dist/index.js", | ||
|
@@ -45,7 +45,7 @@ | |
"devDependencies": { | ||
"@babel/preset-env": "^7.20.2", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@buildinams/lint": "^0.0.2", | ||
"@buildinams/lint": "^0.0.3", | ||
"@testing-library/react": "^13.4.0", | ||
"@types/jest": "^29.2.5", | ||
"@types/node": "^18.11.18", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,5 @@ | ||
import { Config } from "./types"; | ||
import { Target } from "./types"; | ||
|
||
export const getEventTargetFromConfig = (config?: Config) => { | ||
if (config?.target) { | ||
const { target } = config; | ||
|
||
// If the target is a ref... | ||
if ("current" in target) { | ||
// ...and the ref has a value, return it | ||
if (target.current) return target.current; | ||
} | ||
|
||
// Otherwise, return the target | ||
else return target; | ||
} | ||
|
||
// If no target is specified, or it's null, return window | ||
return window; | ||
export const getEventTargetFromTarget = (target?: Target) => { | ||
return (target && "current" in target ? target.current : target) || window; | ||
}; |
Oops, something went wrong.