From a3dba7aab180486c5711f5d5231974a7e68211ab Mon Sep 17 00:00:00 2001 From: Andrii Ieroshenko Date: Wed, 10 Jan 2024 13:28:10 -0800 Subject: [PATCH] memoize RendermimeMarkdown (10% faster) --- packages/jupyter-ai/src/components/rendermime-markdown.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/jupyter-ai/src/components/rendermime-markdown.tsx b/packages/jupyter-ai/src/components/rendermime-markdown.tsx index 58a5bbd08..ddabb7e02 100644 --- a/packages/jupyter-ai/src/components/rendermime-markdown.tsx +++ b/packages/jupyter-ai/src/components/rendermime-markdown.tsx @@ -12,9 +12,7 @@ type RendermimeMarkdownProps = { rmRegistry: IRenderMimeRegistry; }; -export function RendermimeMarkdown( - props: RendermimeMarkdownProps -): JSX.Element { +function RendermimeMarkdownBase(props: RendermimeMarkdownProps): JSX.Element { const [renderedContent, setRenderedContent] = useState( null ); @@ -57,3 +55,5 @@ export function RendermimeMarkdown( ); } + +export const RendermimeMarkdown = React.memo(RendermimeMarkdownBase);