Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add ref.current element to hook dependencies

+12 -10
+1 -1
src/useDialogFocus.ts
··· 178 178 document.body.removeEventListener('focusin', onFocus); 179 179 document.removeEventListener('keydown', onKey); 180 180 }; 181 - }, [ref, disabled, hasPriority]); 181 + }, [ref.current!, disabled, hasPriority]); 182 182 }
+1 -1
src/useDismissable.ts
··· 80 80 document.removeEventListener('touchstart', onClick); 81 81 document.removeEventListener('keydown', onKey); 82 82 }; 83 - }, [ref.current, hasPriority, disabled, focusLoss]); 83 + }, [ref.current!, hasPriority, disabled, focusLoss]); 84 84 }
+1 -1
src/useMenuFocus.ts
··· 129 129 document.body.removeEventListener('focusin', onFocus); 130 130 document.removeEventListener('keydown', onKey); 131 131 }; 132 - }, [ref, disabled]); 132 + }, [ref.current!, disabled]); 133 133 }
+1 -1
src/useModalFocus.ts
··· 76 76 document.body.removeEventListener('focusout', onBlur); 77 77 document.removeEventListener('keydown', onKeyDown); 78 78 }; 79 - }, [ref, hasPriority, disabled]); 79 + }, [ref.current!, hasPriority, disabled]); 80 80 }
+1 -1
src/usePriority.ts
··· 52 52 listeners.delete(onChange); 53 53 listeners.forEach(fn => fn()); 54 54 }; 55 - }, [ref, isDisabled]); 55 + }, [ref.current!, isDisabled]); 56 56 57 57 return hasPriority; 58 58 };
+7 -5
src/useScrollRestoration.ts
··· 10 10 export function useScrollRestoration<T extends HTMLElement>( 11 11 ref: 'window' | Ref<T> 12 12 ) { 13 + const target = ref !== 'window' ? ref.current : ref; 14 + 13 15 useLayoutEffect(() => { 14 16 let unsubscribe: void | (() => void); 15 - if (ref !== 'window' && !ref.current) return; 17 + if (!target) return; 16 18 17 - const addonId = ref === 'window' ? 'window' : ref.current!.id || ''; 18 - const eventTarget = ref === 'window' ? window : ref.current!; 19 - const scrollTarget = ref === 'window' ? document.body : ref.current!; 19 + const addonId = target === 'window' ? 'window' : target.id || ''; 20 + const eventTarget = target === 'window' ? window : target; 21 + const scrollTarget = target === 'window' ? document.body : target; 20 22 21 23 function restoreScroll(event?: PopStateEvent) { 22 24 const id = addonId + getIdForState(event ? event.state : history.state); ··· 75 77 window.removeEventListener('popstate', restoreScroll); 76 78 if (unsubscribe) unsubscribe(); 77 79 }; 78 - }, [ref]); 80 + }, [target]); 79 81 }