From 2f33aa8182c92bf56d49ec3184e6b20f0c0c1e1e Mon Sep 17 00:00:00 2001 From: kodai3 Date: Tue, 9 Mar 2021 23:00:21 +0900 Subject: [PATCH] fix: use window inside useEffect --- src/useOrientation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/useOrientation.ts b/src/useOrientation.ts index cb315218b6..fb6aad7731 100644 --- a/src/useOrientation.ts +++ b/src/useOrientation.ts @@ -12,10 +12,10 @@ const defaultState: OrientationState = { }; const useOrientation = (initialState: OrientationState = defaultState) => { - const screen = window.screen; const [state, setState] = useState(initialState); useEffect(() => { + const screen = window.screen; let mounted = true; const onChange = () => {