memoization

This commit is contained in:
Tom Moor
2021-10-14 21:23:28 -07:00
parent 5299ada3c9
commit cc7a50fbb1

View File

@@ -31,6 +31,10 @@ type Props = {|
scrollIntoViewIfNeeded?: boolean, scrollIntoViewIfNeeded?: boolean,
|}; |};
const activeDropStyle = {
fontWeight: 600,
};
function SidebarLink( function SidebarLink(
{ {
icon, icon,
@@ -55,22 +59,22 @@ function SidebarLink(
}: Props, }: Props,
ref ref
) { ) {
const style = React.useMemo(() => { const style = React.useMemo(
return { () => ({
paddingLeft: `${(depth || 0) * 16 + 12}px`, paddingLeft: `${(depth || 0) * 16 + 12}px`,
}; }),
}, [depth]); [depth]
);
const activeStyle = { const activeStyle = React.useMemo(
fontWeight: 600, () => ({
color: theme.text, fontWeight: 600,
background: theme.sidebarItemBackground, color: theme.text,
...style, background: theme.sidebarItemBackground,
}; ...style,
}),
const activeDropStyle = { [theme, style]
fontWeight: 600, );
};
return ( return (
<> <>