Skip to content

Commit ac6d3ff

Browse files
committed
fix: Inbox and Popup re-rendering needlessly
Previously we'd incorrectly pass their `children` into `useUIBox` which would cause the UIBoxes to be destroyed and re-initialized over and over.
1 parent faf5bdc commit ac6d3ff

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/ui/Inbox.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function ActiveInbox(props: InboxProps & { session: Talk.Session }) {
5050
style,
5151
className,
5252
loadingComponent,
53+
children,
5354
...optionsAndEvents
5455
} = props;
5556

@@ -77,6 +78,7 @@ function ActiveInbox(props: InboxProps & { session: Talk.Session }) {
7778
style={style}
7879
loadingComponent={loadingComponent}
7980
handlers={events}
81+
children={children}
8082
/>
8183
);
8284
}

lib/ui/Popup.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { useSetter, useConversation, useUIBox, useMountBox } from "../hooks";
99
import { EventListeners } from "../EventListeners";
1010
import { UIBoxProps } from "../types";
11+
import { BoxContext } from "../MountedBox";
1112

1213
type PopupProps = UIBoxProps<Talk.Popup> &
1314
Talk.PopupOptions & {
@@ -38,6 +39,7 @@ function ActivePopup(props: PopupProps & { session: Talk.Session }) {
3839
conversationId,
3940
syncConversation,
4041
popupRef,
42+
children,
4143
...optionsAndEvents
4244
} = props;
4345

@@ -52,5 +54,10 @@ function ActivePopup(props: PopupProps & { session: Talk.Session }) {
5254
useConversation(session, box, syncConversation, conversationId);
5355
useMountBox(box, undefined);
5456

55-
return <EventListeners target={box} handlers={events} />;
57+
return (
58+
<BoxContext.Provider value={box}>
59+
{children}
60+
<EventListeners target={box} handlers={events} />
61+
</BoxContext.Provider>
62+
);
5663
}

0 commit comments

Comments
 (0)