Skip to content

Commit

Permalink
Merge pull request #625 from krabbi/prevent_unnecessary_renders
Browse files Browse the repository at this point in the history
[FE]Prevent unneccessary renders.
  • Loading branch information
dartpain authored Oct 19, 2023
2 parents 4ed6580 + 0a717ae commit f587af1
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions frontend/src/conversation/ConversationBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const ConversationBubble = forwardRef<
{ message, type, className, feedback, handleFeedback, sources },
ref,
) {
const [showFeedback, setShowFeedback] = useState(false);
const [openSource, setOpenSource] = useState<number | null>(null);
const [copied, setCopied] = useState(false);

Expand Down Expand Up @@ -56,12 +55,7 @@ const ConversationBubble = forwardRef<
);
} else {
bubble = (
<div
ref={ref}
className={`flex self-start ${className} flex-col`}
onMouseEnter={() => setShowFeedback(true)}
onMouseLeave={() => setShowFeedback(false)}
>
<div ref={ref} className={`flex self-start ${className} group flex-col`}>
<div className="flex self-start">
<Avatar className="mt-2 text-2xl" avatar="🦖"></Avatar>
<div
Expand Down Expand Up @@ -152,8 +146,8 @@ const ConversationBubble = forwardRef<
)}
</div>
<div
className={`relative mr-2 flex items-center justify-center ${
type !== 'ERROR' && showFeedback ? '' : 'md:invisible'
className={`relative mr-2 flex items-center justify-center md:invisible ${
type !== 'ERROR' ? 'group-hover:md:visible' : ''
}`}
>
{copied ? (
Expand All @@ -168,10 +162,10 @@ const ConversationBubble = forwardRef<
)}
</div>
<div
className={`relative mr-2 flex items-center justify-center ${
feedback === 'LIKE' || (type !== 'ERROR' && showFeedback)
? ''
: 'md:invisible'
className={`relative mr-2 flex items-center justify-center md:invisible ${
feedback === 'LIKE' || type !== 'ERROR'
? 'group-hover:md:visible'
: ''
}`}
>
<Like
Expand All @@ -184,10 +178,10 @@ const ConversationBubble = forwardRef<
></Like>
</div>
<div
className={`relative mr-10 flex items-center justify-center ${
feedback === 'DISLIKE' || (type !== 'ERROR' && showFeedback)
? ''
: 'md:invisible'
className={`relative mr-10 flex items-center justify-center md:invisible ${
feedback === 'DISLIKE' || type !== 'ERROR'
? 'group-hover:md:visible'
: ''
}`}
>
<Dislike
Expand Down

2 comments on commit f587af1

@vercel
Copy link

@vercel vercel bot commented on f587af1 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextra-docsgpt – ./docs

nextra-docsgpt-git-main-arc53.vercel.app
docs.docsgpt.co.uk
nextra-docsgpt.vercel.app
nextra-docsgpt-arc53.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f587af1 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-gpt – ./frontend

docs-gpt-brown.vercel.app
docs-gpt-git-main-arc53.vercel.app
docs-gpt-arc53.vercel.app

Please sign in to comment.