Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/internal/container-queries/use-resize-observer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { unstable_batchedUpdates } from 'react-dom';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that react-dom is a dev dependency —is this okay? Consumers of this package might not get it installed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { ResizeObserver, ResizeObserverEntry } from '@juggle/resize-observer';
import { useEffect, useLayoutEffect } from 'react';
import { ContainerQueryEntry, ElementReference } from './interfaces';
Expand Down Expand Up @@ -56,7 +57,9 @@ export function useResizeObserver(elementRef: ElementReference, onObserve: (entr
const observer = new ResizeObserver(entries => {
// Prevent observe notifications on already unmounted component.
if (connected) {
stableOnObserve(convertResizeObserverEntry(entries[0]));
unstable_batchedUpdates(() => {
stableOnObserve(convertResizeObserverEntry(entries[0]));
});
}
});
observer.observe(element);
Expand Down
Loading