Skip to content

Commit

Permalink
Fix useDimensions initial value issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzasse committed Oct 27, 2024
1 parent b88687a commit 1dc8c88
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useState,
} from 'react';

import { type BoundingBox } from 'framer-motion';
import { isBrowser, type BoundingBox } from 'framer-motion';

import { IS_SSR } from './constants';
import { type SheetEvents } from './types';
Expand Down Expand Up @@ -67,7 +67,10 @@ export function useEventCallbacks(
}

export function useDimensions() {
const [dimensions, setDimensions] = useState({ height: 0, width: 0 });
const [dimensions, setDimensions] = useState({
height: isBrowser ? window.innerHeight : 0,
width: isBrowser ? window.innerWidth : 0,
});

useIsomorphicLayoutEffect(() => {
function handler() {
Expand Down

0 comments on commit 1dc8c88

Please sign in to comment.