feat(ui): memoize all components

This commit is contained in:
psychedelicious
2023-12-29 14:05:56 +11:00
committed by Kent Keirsey
parent ca4b8e65c1
commit 56527da73e
65 changed files with 1165 additions and 970 deletions

View File

@@ -1,24 +1,33 @@
import { Button, forwardRef } from '@chakra-ui/react';
import { InvTooltip } from 'common/components/InvTooltip/InvTooltip';
import { memo } from 'react';
import type { InvButtonProps } from './types';
export const InvButton = forwardRef<InvButtonProps, typeof Button>(
({ isChecked, tooltip, children, ...rest }: InvButtonProps, ref) => {
if (tooltip) {
export const InvButton = memo(
forwardRef<InvButtonProps, typeof Button>(
({ isChecked, tooltip, children, ...rest }: InvButtonProps, ref) => {
if (tooltip) {
return (
<InvTooltip label={tooltip}>
<Button
ref={ref}
colorScheme={isChecked ? 'blue' : 'base'}
{...rest}
>
{children}
</Button>
</InvTooltip>
);
}
return (
<InvTooltip label={tooltip}>
<Button ref={ref} colorScheme={isChecked ? 'blue' : 'base'} {...rest}>
{children}
</Button>
</InvTooltip>
<Button ref={ref} colorScheme={isChecked ? 'blue' : 'base'} {...rest}>
{children}
</Button>
);
}
return (
<Button ref={ref} colorScheme={isChecked ? 'blue' : 'base'} {...rest}>
{children}
</Button>
);
}
)
);
InvButton.displayName = 'InvButton';