From 7d65915d80af4e88dc8f23b8ff9cabc653e6c90b Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Tue, 8 Apr 2025 18:50:28 -0600 Subject: [PATCH] mounted update --- .../ui/layouts/AppSplitter/AppSplitter.tsx | 7 +++++- .../ChatLayout/ChatLayout/ChatLayout.tsx | 22 +++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx b/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx index 53927c83b..a7d7ec1fc 100644 --- a/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx +++ b/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useMemoizedFn } from '@/hooks'; +import { useMemoizedFn, useMount } from '@/hooks'; import React, { useEffect, useMemo, @@ -251,6 +251,11 @@ export const AppSplitter = React.memo( // Add useImperativeHandle to expose the function useImperativeHandle(ref, imperativeHandleMethods); + const isNested = useMemo(() => { + console.log('ref', ref); + return !!ref; + }, [ref]); + return (
= ({ children }) => { const appSplitterRef = useRef(null); + const [mounted, setMounted] = useState(false); + const chatLayoutProps = useChatLayoutContext({ appSplitterRef }); const { selectedLayout, selectedFile } = chatLayoutProps; @@ -23,22 +26,19 @@ export const ChatLayout: React.FC = ({ children }) => { return ['380px', 'auto']; }, [selectedLayout]); + useMount(() => { + setMounted(true); //we need to wait for the app splitter to be mounted because this is nested in the app splitter + }); + return ( ( - - ), - [] - )} + leftChildren={useMemo(() => mounted && , [mounted])} rightChildren={useMemo( - () => ( - {children} - ), - [children] + () => mounted && {children}, + [children, mounted] )} autoSaveId="chat-splitter" defaultLayout={defaultSplitterLayout}