fix: memoize components and improve performance (#579)
This commit is contained in:
parent
a13368cfcd
commit
e839007580
16 changed files with 453 additions and 232 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { SetStateAction } from 'react';
|
||||
import { memo, type SetStateAction } from 'react';
|
||||
|
||||
import type { UIBlock } from './block';
|
||||
import { FileIcon, LoaderIcon, MessageIcon, PencilEditIcon } from './icons';
|
||||
|
|
@ -28,7 +28,7 @@ interface DocumentToolResultProps {
|
|||
setBlock: (value: SetStateAction<UIBlock>) => void;
|
||||
}
|
||||
|
||||
export function DocumentToolResult({
|
||||
function PureDocumentToolResult({
|
||||
type,
|
||||
result,
|
||||
setBlock,
|
||||
|
|
@ -73,17 +73,15 @@ export function DocumentToolResult({
|
|||
);
|
||||
}
|
||||
|
||||
export const DocumentToolResult = memo(PureDocumentToolResult, () => true);
|
||||
|
||||
interface DocumentToolCallProps {
|
||||
type: 'create' | 'update' | 'request-suggestions';
|
||||
args: { title: string };
|
||||
setBlock: (value: SetStateAction<UIBlock>) => void;
|
||||
}
|
||||
|
||||
export function DocumentToolCall({
|
||||
type,
|
||||
args,
|
||||
setBlock,
|
||||
}: DocumentToolCallProps) {
|
||||
function PureDocumentToolCall({ type, args, setBlock }: DocumentToolCallProps) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -125,3 +123,5 @@ export function DocumentToolCall({
|
|||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export const DocumentToolCall = memo(PureDocumentToolCall, () => true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue