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,
|};
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 (
<>