Skip to content

Commit d3844f5

Browse files
authored
fix react 19 refs (#124)
1 parent c586de2 commit d3844f5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/useClickOutside.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function isModifiedEvent(event: MouseEvent) {
2323
}
2424

2525
export const getRefTarget = (
26-
ref: React.RefObject<Element> | Element | null | undefined,
26+
ref: React.RefObject<Element | null> | Element | null | undefined,
2727
) => ref && ('current' in ref ? ref.current : ref);
2828

2929
export interface ClickOutsideOptions {
@@ -41,14 +41,14 @@ const InitialTriggerEvents: Partial<Record<MouseEvents, MouseEvents>> = {
4141
* The `useClickOutside` hook registers your callback on the document that fires
4242
* when a pointer event is registered outside of the provided ref or element.
4343
*
44-
* @param {Ref<HTMLElement>| HTMLElement} ref The element boundary
44+
* @param {Ref<HTMLElement | null>| HTMLElement} ref The element boundary
4545
* @param {function} onClickOutside
4646
* @param {object=} options
4747
* @param {boolean=} options.disabled
4848
* @param {string=} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on
4949
*/
5050
function useClickOutside(
51-
ref: React.RefObject<Element> | Element | null | undefined,
51+
ref: React.RefObject<Element | null> | Element | null | undefined,
5252
onClickOutside: (e: Event) => void = noop,
5353
{ disabled, clickTrigger = 'click' }: ClickOutsideOptions = {},
5454
) {

src/useRootClose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface RootCloseOptions extends ClickOutsideOptions {
2828
* @param {string=} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on
2929
*/
3030
function useRootClose(
31-
ref: React.RefObject<Element> | Element | null | undefined,
31+
ref: React.RefObject<Element | null> | Element | null | undefined,
3232
onRootClose: (e: Event) => void,
3333
{ disabled, clickTrigger }: RootCloseOptions = {},
3434
) {

0 commit comments

Comments
 (0)