From ec115f749fea1c545663888c8d2cfc0bd3cfa514 Mon Sep 17 00:00:00 2001 From: Trevor <7311041+tjuanitas@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:33:38 -0700 Subject: [PATCH] perf(content-answers): lazy load content answers in preview (#3720) * perf(content-answers): lazy load content answers in preview * fix: flow ignore for TS component --- .../common/content-answers/ContentAnswers.tsx | 8 +++++--- .../common/content-answers/ContentAnswersModal.tsx | 2 -- .../preview-header/PreviewHeader.js | 14 +++++++++++--- .../preview-header/PreviewHeader.scss | 6 ++++++ .../preview-header/__tests__/PreviewHeader.test.js | 6 ++---- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/elements/common/content-answers/ContentAnswers.tsx b/src/elements/common/content-answers/ContentAnswers.tsx index 9080e8b20b..a25aad94cf 100644 --- a/src/elements/common/content-answers/ContentAnswers.tsx +++ b/src/elements/common/content-answers/ContentAnswers.tsx @@ -4,7 +4,6 @@ import getProp from 'lodash/get'; import ContentAnswersModal, { ExternalProps as ContentAnswersModalExternalProps } from './ContentAnswersModal'; import ContentAnswersOpenButton from './ContentAnswersOpenButton'; // @ts-ignore: no ts definition -// eslint-disable-next-line import/named import { BoxItem } from '../../common/types/core'; interface ExternalProps extends ContentAnswersModalExternalProps { @@ -12,10 +11,13 @@ interface ExternalProps extends ContentAnswersModalExternalProps { } interface Props { + className?: string; file: BoxItem; } -const ContentAnswers = ({ file, onAsk, onRequestClose, ...rest }: ContentAnswersModalExternalProps & Props) => { +const ContentAnswers = (props: ContentAnswersModalExternalProps & Props) => { + const { className = '', file, onAsk, onRequestClose, ...rest } = props; + const [isModalOpen, setIsModalOpen] = useState(false); const [hasQuestions, setHasQuestions] = useState(false); const [isHighlighted, setIsHighlighted] = useState(false); @@ -44,7 +46,7 @@ const ContentAnswers = ({ file, onAsk, onRequestClose, ...rest }: ContentAnswers const currentExtension = getProp(file, 'extension'); return ( -