Skip to content

Commit

Permalink
Use useLayoutEffect for setting the aspect-ratio to avoid flashing …
Browse files Browse the repository at this point in the history
…inactive slides on load.
  • Loading branch information
cpojer committed Oct 18, 2023
1 parent 5dc53f3 commit 8ac731d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/remdx/src/hooks/use-aspect-ratio-fitting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
import useResizeObserver, { ResizeHandler } from 'use-resize-observer';

export default function useAspectRatioFitting(aspectRatio: number) {
Expand Down Expand Up @@ -42,7 +42,7 @@ export default function useAspectRatioFitting(aspectRatio: number) {
[targetWidth, targetHeight],
);

useEffect(() => {
useLayoutEffect(() => {
if (!containerRef || !containerRef.current) {
return;
}
Expand Down

0 comments on commit 8ac731d

Please sign in to comment.