From cc7a50fbb15d8030e1997c0e471c6aaf4bb59c7e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 14 Oct 2021 21:23:28 -0700 Subject: [PATCH] memoization --- .../Sidebar/components/SidebarLink.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/components/Sidebar/components/SidebarLink.js b/app/components/Sidebar/components/SidebarLink.js index 65857439..b0efc5b4 100644 --- a/app/components/Sidebar/components/SidebarLink.js +++ b/app/components/Sidebar/components/SidebarLink.js @@ -31,6 +31,10 @@ type Props = {| scrollIntoViewIfNeeded?: boolean, |}; +const activeDropStyle = { + fontWeight: 600, +}; + function SidebarLink( { icon, @@ -55,22 +59,22 @@ function SidebarLink( }: Props, ref ) { - const style = React.useMemo(() => { - return { + const style = React.useMemo( + () => ({ paddingLeft: `${(depth || 0) * 16 + 12}px`, - }; - }, [depth]); + }), + [depth] + ); - const activeStyle = { - fontWeight: 600, - color: theme.text, - background: theme.sidebarItemBackground, - ...style, - }; - - const activeDropStyle = { - fontWeight: 600, - }; + const activeStyle = React.useMemo( + () => ({ + fontWeight: 600, + color: theme.text, + background: theme.sidebarItemBackground, + ...style, + }), + [theme, style] + ); return ( <>