fix: memoize components and improve performance (#579)

This commit is contained in:
Jeremy 2024-12-03 17:49:38 +03:00 committed by GitHub
parent a13368cfcd
commit e839007580
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 453 additions and 232 deletions

View file

@ -0,0 +1,28 @@
import { memo, SetStateAction } from 'react';
import { CrossIcon } from './icons';
import { Button } from './ui/button';
import { UIBlock } from './block';
import equal from 'fast-deep-equal';
interface BlockCloseButtonProps {
setBlock: (value: SetStateAction<UIBlock>) => void;
}
function PureBlockCloseButton({ setBlock }: BlockCloseButtonProps) {
return (
<Button
variant="outline"
className="h-fit p-2 dark:hover:bg-zinc-700"
onClick={() => {
setBlock((currentBlock) => ({
...currentBlock,
isVisible: false,
}));
}}
>
<CrossIcon size={18} />
</Button>
);
}
export const BlockCloseButton = memo(PureBlockCloseButton, () => true);