mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): memoize all components
This commit is contained in:
committed by
Kent Keirsey
parent
ca4b8e65c1
commit
56527da73e
@@ -2,28 +2,32 @@ import { forwardRef, Textarea as ChakraTextarea } from '@chakra-ui/react';
|
||||
import { useGlobalModifiersSetters } from 'common/hooks/useGlobalModifiers';
|
||||
import { stopPastePropagation } from 'common/util/stopPastePropagation';
|
||||
import type { KeyboardEvent } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { memo, useCallback } from 'react';
|
||||
|
||||
import type { InvTextareaProps } from './types';
|
||||
|
||||
export const InvTextarea = forwardRef<InvTextareaProps, typeof ChakraTextarea>(
|
||||
(props: InvTextareaProps, ref) => {
|
||||
const { ...rest } = props;
|
||||
const { setShift } = useGlobalModifiersSetters();
|
||||
const onKeyUpDown = useCallback(
|
||||
(e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
setShift(e.shiftKey);
|
||||
},
|
||||
[setShift]
|
||||
);
|
||||
return (
|
||||
<ChakraTextarea
|
||||
ref={ref}
|
||||
onPaste={stopPastePropagation}
|
||||
onKeyUp={onKeyUpDown}
|
||||
onKeyDown={onKeyUpDown}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export const InvTextarea = memo(
|
||||
forwardRef<InvTextareaProps, typeof ChakraTextarea>(
|
||||
(props: InvTextareaProps, ref) => {
|
||||
const { ...rest } = props;
|
||||
const { setShift } = useGlobalModifiersSetters();
|
||||
const onKeyUpDown = useCallback(
|
||||
(e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
setShift(e.shiftKey);
|
||||
},
|
||||
[setShift]
|
||||
);
|
||||
return (
|
||||
<ChakraTextarea
|
||||
ref={ref}
|
||||
onPaste={stopPastePropagation}
|
||||
onKeyUp={onKeyUpDown}
|
||||
onKeyDown={onKeyUpDown}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
InvTextarea.displayName = 'InvTextarea';
|
||||
|
||||
Reference in New Issue
Block a user