optimize various base components

This commit is contained in:
jeffvli
2026-01-02 12:46:35 -08:00
parent a66c67e86d
commit d06d1674d1
31 changed files with 669 additions and 393 deletions
+11 -4
View File
@@ -1,18 +1,21 @@
import { Center as MantineCenter, CenterProps as MantineCenterProps } from '@mantine/core';
import { forwardRef, MouseEvent } from 'react';
import { forwardRef, memo, MouseEvent, useMemo } from 'react';
export interface CenterProps extends MantineCenterProps {
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
}
export const Center = forwardRef<HTMLDivElement, CenterProps>(
const _Center = forwardRef<HTMLDivElement, CenterProps>(
({ children, classNames, onClick, style, ...props }, ref) => {
const memoizedClassNames = useMemo(() => ({ ...classNames }), [classNames]);
const memoizedStyle = useMemo(() => ({ ...style }), [style]);
return (
<MantineCenter
classNames={{ ...classNames }}
classNames={memoizedClassNames}
onClick={onClick}
ref={ref}
style={{ ...style }}
style={memoizedStyle}
{...props}
>
{children}
@@ -20,3 +23,7 @@ export const Center = forwardRef<HTMLDivElement, CenterProps>(
);
},
);
_Center.displayName = 'Center';
export const Center = memo(_Center);