Skip to content

Commit

Permalink
Set ref to non-mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitch-At-Work committed Sep 23, 2024
1 parent e628416 commit 9e8be32
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const useDynamicVirtualizerMeasure: <TElement extends HTMLElement>(virtua
bufferItems: number;
bufferSize: number;
scrollRef: (instance: TElement | null) => void;
containerSizeRef: React_2.MutableRefObject<number>;
containerSizeRef: React_2.RefObject<number>;
};

// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export type VirtualizerConfigProps = {
* A ref that provides the size of container (vertical - height, horizontal - width), set by a resize observer.
* Virtualizer Measure hooks provide a suitable reference.
*/
containerSizeRef: MutableRefObject<number>;
containerSizeRef: RefObject<number>;
};

export type VirtualizerProps = ComponentProps<Partial<VirtualizerSlots>> & VirtualizerConfigProps;
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerSta
// Ignore buffer size (IO offset)
measurementPos -= bufferSize;
// we hit the after buffer and detected the end of view, we need to find the start index.
measurementPos -= containerSizeRef.current;
measurementPos -= containerSizeRef.current ?? 0;

// Calculate how far past the window bounds we are (this will be zero if IO is within window)
const hOverflow = latestEntry.boundingClientRect.top - latestEntry.intersectionRect.top;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useDynamicVirtualizerMeasure = <TElement extends HTMLElement>(
bufferItems: number;
bufferSize: number;
scrollRef: (instance: TElement | null) => void;
containerSizeRef: React.MutableRefObject<number>;
containerSizeRef: React.RefObject<number>;
} => {
const {
defaultItemSize,
Expand Down

0 comments on commit 9e8be32

Please sign in to comment.