mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-16 13:15:08 -05:00
feat(ui): memoize all components
This commit is contained in:
committed by
Kent Keirsey
parent
ca4b8e65c1
commit
56527da73e
@@ -1,27 +1,32 @@
|
||||
import { forwardRef, IconButton } from '@chakra-ui/react';
|
||||
import type { InvIconButtonProps } from 'common/components/InvIconButton/types';
|
||||
import { InvTooltip } from 'common/components/InvTooltip/InvTooltip';
|
||||
import { memo } from 'react';
|
||||
|
||||
export const InvIconButton = memo(
|
||||
forwardRef<InvIconButtonProps, typeof IconButton>(
|
||||
({ isChecked, tooltip, ...rest }: InvIconButtonProps, ref) => {
|
||||
if (tooltip) {
|
||||
return (
|
||||
<InvTooltip label={tooltip}>
|
||||
<IconButton
|
||||
ref={ref}
|
||||
colorScheme={isChecked ? 'blue' : 'base'}
|
||||
{...rest}
|
||||
/>
|
||||
</InvTooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export const InvIconButton = forwardRef<InvIconButtonProps, typeof IconButton>(
|
||||
({ isChecked, tooltip, ...rest }: InvIconButtonProps, ref) => {
|
||||
if (tooltip) {
|
||||
return (
|
||||
<InvTooltip label={tooltip}>
|
||||
<IconButton
|
||||
ref={ref}
|
||||
colorScheme={isChecked ? 'blue' : 'base'}
|
||||
{...rest}
|
||||
/>
|
||||
</InvTooltip>
|
||||
<IconButton
|
||||
ref={ref}
|
||||
colorScheme={isChecked ? 'blue' : 'base'}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
ref={ref}
|
||||
colorScheme={isChecked ? 'blue' : 'base'}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
InvIconButton.displayName = 'InvIconButton';
|
||||
|
||||
Reference in New Issue
Block a user