From a9d5dd7fc8639ab8b8e16c12f66719cba478351a Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 4 Oct 2022 23:17:09 -0700 Subject: [PATCH] Memoize `FeedBet` component (#999) --- web/components/feed/feed-bets.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/components/feed/feed-bets.tsx b/web/components/feed/feed-bets.tsx index b2852739..900265cb 100644 --- a/web/components/feed/feed-bets.tsx +++ b/web/components/feed/feed-bets.tsx @@ -1,3 +1,4 @@ +import React, { memo, useEffect } from 'react' import dayjs from 'dayjs' import { Contract } from 'common/contract' import { Bet } from 'common/bet' @@ -8,7 +9,6 @@ import clsx from 'clsx' import { formatMoney, formatPercent } from 'common/util/format' import { OutcomeLabel } from 'web/components/outcome-label' import { RelativeTimestamp } from 'web/components/relative-timestamp' -import React, { useEffect } from 'react' import { formatNumericProbability } from 'common/pseudo-numeric' import { SiteLink } from 'web/components/site-link' import { getChallenge, getChallengeUrl } from 'web/lib/firebase/challenges' @@ -16,7 +16,10 @@ import { Challenge } from 'common/challenge' import { UserLink } from 'web/components/user-link' import { BETTOR } from 'common/user' -export function FeedBet(props: { contract: Contract; bet: Bet }) { +export const FeedBet = memo(function FeedBet(props: { + contract: Contract + bet: Bet +}) { const { contract, bet } = props const { userAvatarUrl, userUsername, createdTime } = bet const showUser = dayjs(createdTime).isAfter('2022-06-01') @@ -36,7 +39,7 @@ export function FeedBet(props: { contract: Contract; bet: Bet }) { /> ) -} +}) export function BetStatusText(props: { contract: Contract