From 886a6721b37adb13a7a46b305c11ed280f97e5dc Mon Sep 17 00:00:00 2001 From: dan-klasson Date: Thu, 1 Sep 2022 11:18:11 +0100 Subject: [PATCH] Make target option support undefined (#1353) It should be possible to use the ref without having to declare it as null --- .changeset/forty-seals-confess.md | 5 +++++ packages/rooks/src/hooks/useKeys.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/forty-seals-confess.md diff --git a/.changeset/forty-seals-confess.md b/.changeset/forty-seals-confess.md new file mode 100644 index 0000000000..762eb9c171 --- /dev/null +++ b/.changeset/forty-seals-confess.md @@ -0,0 +1,5 @@ +--- +"rooks": patch +--- + +Make useKey target option support undefined diff --git a/packages/rooks/src/hooks/useKeys.ts b/packages/rooks/src/hooks/useKeys.ts index 7ed66ea427..5b02bba0b6 100644 --- a/packages/rooks/src/hooks/useKeys.ts +++ b/packages/rooks/src/hooks/useKeys.ts @@ -16,7 +16,7 @@ type Options = { * target ref on which the events should be listened. If no target is specified, * events are listened to on the document */ - target?: MutableRefObject | MutableRefObject; + target?: MutableRefObject | MutableRefObject; /** * when boolean to enable and disable events, when passed false * remove the eventlistener if any