memoization
This commit is contained in:
@@ -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 (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user