Skip to content

Commit

Permalink
assign isomorphic effect properly
Browse files Browse the repository at this point in the history
should address issue #30.
also bumps to 0.7.0-alpha.1 for pushing to NPM
  • Loading branch information
rob2d committed Jul 7, 2023
1 parent 1e03d75 commit a950710
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {
useMemo,
useCallback,
useRef,
useLayoutEffect,
useEffect,
useLayoutEffect
} from 'react';

function getVpWidth() {
Expand All @@ -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 //
Expand Down

0 comments on commit a950710

Please sign in to comment.