@@ -9,11 +9,13 @@ import { useMethod, useConversation, useUIBox, useMountBox } from "../hooks";
99import { EventListeners } from "../EventListeners" ;
1010import { UIBoxProps } from "../types" ;
1111import { BoxContext } from "../MountedBox" ;
12+ import { useEffect } from "react" ;
1213
1314type PopupProps = UIBoxProps < Talk . Popup > &
1415 Talk . PopupOptions & {
1516 highlightedWords ?: Parameters < Talk . Popup [ "setHighlightedWords" ] > [ 0 ] ;
1617 popupRef ?: React . MutableRefObject < Talk . Popup | undefined > ;
18+ show ?: boolean ;
1719 children ?: React . ReactNode ;
1820 } ;
1921
@@ -39,6 +41,7 @@ function ActivePopup(props: PopupProps & { session: Talk.Session }) {
3941 conversationId,
4042 syncConversation,
4143 asGuest,
44+ show,
4245 popupRef,
4346 children,
4447 ...optionsAndEvents
@@ -53,7 +56,20 @@ function ActivePopup(props: PopupProps & { session: Talk.Session }) {
5356 useMethod ( box , presence , "setPresence" ) ;
5457 useMethod ( box , highlightedWords , "setHighlightedWords" ) ;
5558 useConversation ( session , box , syncConversation , conversationId , asGuest ) ;
56- useMountBox ( box , undefined ) ;
59+ const mounted = useMountBox ( box , { show : show ?? true } ) ;
60+
61+ useEffect ( ( ) => {
62+ if ( show === undefined || ! mounted ) {
63+ return ;
64+ }
65+
66+ if ( show ) {
67+ box ?. show ( ) ;
68+ } else {
69+ box ?. hide ( ) ;
70+ }
71+
72+ } , [ show , mounted , box ] )
5773
5874 return (
5975 < BoxContext . Provider value = { box } >
0 commit comments