From 6da0790367e75afb4584f41ad11325c0e255fe2d Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Wed, 18 Oct 2023 19:54:23 +0200 Subject: [PATCH] perf(media): use else if statements instead of dynamic jsx object --- src/components/expando/expando.tsx | 24 ++++++++++++++---------- src/components/thumbnail/thumbnail.tsx | 23 ++++++++++++----------- src/lib/utils.ts | 2 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/expando/expando.tsx b/src/components/expando/expando.tsx index caf5fe6b..f86ceee0 100644 --- a/src/components/expando/expando.tsx +++ b/src/components/expando/expando.tsx @@ -4,7 +4,6 @@ import utils from '../../lib/utils'; import { Link } from 'react-router-dom'; import styles from './expando.module.css'; import Embed from '../embed'; -import { CommentMediaInfo } from '../../lib/utils'; interface ExpandoProps { commentCid: string; @@ -16,21 +15,26 @@ const Expando: FC = ({ commentCid, expanded }) => { const { cid, content, link, subplebbitAddress } = comment || {}; const commentMediaInfo = utils.getCommentMediaInfoMemoized(comment); - // prettier-ignore - const mediaComponents: { [key in CommentMediaInfo['type']]?: JSX.Element | null } = { - 'image': , - 'video': expanded ?