Skip to content

Commit 1aa0596

Browse files
authored
Merge pull request #28 from cristianbote/wrap-the-get-bounding-client-rect
Wrap the getBoundingClientRect call in a setTimeout
2 parents bcd52db + a452643 commit 1aa0596

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/toast-bar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ export const ToastBar: React.FC<ToastBarProps> = React.memo(
101101
({ toast, position, ...props }) => {
102102
const ref = useCallback((el: HTMLElement | null) => {
103103
if (el) {
104-
const boundingRect = el.getBoundingClientRect();
105-
props.onHeight(boundingRect.height);
104+
setTimeout(() => {
105+
const boundingRect = el.getBoundingClientRect();
106+
props.onHeight(boundingRect.height);
107+
});
106108
}
107109
}, []);
108110

0 commit comments

Comments
 (0)