From 0a717ae82e1c69805f9709fa8a25d321edac2671 Mon Sep 17 00:00:00 2001 From: Alexander Deshkevich Date: Mon, 16 Oct 2023 20:09:59 -0300 Subject: [PATCH] Prevent unneccessary renders. Update show/hide state of feedback buttons by css instead React --- .../src/conversation/ConversationBubble.tsx | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index ad7db7a..83b98cd 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -27,7 +27,6 @@ const ConversationBubble = forwardRef< { message, type, className, feedback, handleFeedback, sources }, ref, ) { - const [showFeedback, setShowFeedback] = useState(false); const [openSource, setOpenSource] = useState(null); const [copied, setCopied] = useState(false); @@ -65,12 +64,7 @@ const ConversationBubble = forwardRef< ); } else { bubble = ( -
setShowFeedback(true)} - onMouseLeave={() => setShowFeedback(false)} - > +
-
- Sources: -
+
Sources:
{sources?.map((source, index) => (
{copied ? ( @@ -167,10 +159,10 @@ const ConversationBubble = forwardRef< )}