From a950710f418d4890554eabc460066cf91c6241a0 Mon Sep 17 00:00:00 2001 From: Robert Concepcion III Date: Fri, 7 Jul 2023 01:16:30 -0400 Subject: [PATCH] assign isomorphic effect properly should address issue #30. also bumps to 0.7.0-alpha.1 for pushing to NPM --- package.json | 2 +- src/index.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 69f67fa..adeeecb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "use-viewport-sizes", - "version": "0.7.0-alpha.0", + "version": "0.7.0-alpha.1", "description": "a tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce or custom memo function for updates for optimal rendering.", "main": "./build/index.js", "types": "./build/index.d.ts", diff --git a/src/index.js b/src/index.js index 1da00e9..7ca00ef 100644 --- a/src/index.js +++ b/src/index.js @@ -3,8 +3,7 @@ import { useMemo, useCallback, useRef, - useLayoutEffect, - useEffect, + useLayoutEffect } from 'react'; function getVpWidth() { @@ -24,9 +23,8 @@ function getVpHeight() { // Avoid useLayoutEffect warning during SSR // https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect -function useIsomorphicLayoutEffect() { - typeof window !== 'undefined' ? useLayoutEffect : useEffect; -} +export const useIsomorphicLayoutEffect = + typeof window !== 'undefined' ? useLayoutEffect : () => {}; // =============== // // Shared State //