Rename to blocks (#502)

This commit is contained in:
Jeremy 2024-11-07 02:40:29 +03:00 committed by GitHub
parent 22a09de6e6
commit 729634e1d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 108 additions and 111 deletions

View file

@ -1,43 +0,0 @@
import { JSONValue } from 'ai';
import { Dispatch, memo, SetStateAction } from 'react';
import { UICanvas } from './canvas';
import { useCanvasStream } from './use-canvas-stream';
interface CanvasStreamHandlerProps {
setCanvas: Dispatch<SetStateAction<UICanvas>>;
streamingData: JSONValue[] | undefined;
}
export function PureCanvasStreamHandler({
setCanvas,
streamingData,
}: CanvasStreamHandlerProps) {
useCanvasStream({
streamingData,
setCanvas,
});
return null;
}
function areEqual(
prevProps: CanvasStreamHandlerProps,
nextProps: CanvasStreamHandlerProps
) {
if (!prevProps.streamingData && !nextProps.streamingData) {
return true;
}
if (!prevProps.streamingData || !nextProps.streamingData) {
return false;
}
if (prevProps.streamingData.length !== nextProps.streamingData.length) {
return false;
}
return true;
}
export const CanvasStreamHandler = memo(PureCanvasStreamHandler, areEqual);