mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-01-22 10:55:34 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { useEffect } from 'react';
|
|
|
|
interface ScreenshotStateManagerProps {
|
|
setUploadedFiles?: (files: File[]) => void;
|
|
setImageDataList?: (dataList: string[]) => void;
|
|
uploadedFiles: File[];
|
|
imageDataList: string[];
|
|
}
|
|
|
|
export const ScreenshotStateManager = ({
|
|
setUploadedFiles,
|
|
setImageDataList,
|
|
uploadedFiles,
|
|
imageDataList,
|
|
}: ScreenshotStateManagerProps) => {
|
|
useEffect(() => {
|
|
if (setUploadedFiles && setImageDataList) {
|
|
(window as any).__BOLT_SET_UPLOADED_FILES__ = setUploadedFiles;
|
|
(window as any).__BOLT_SET_IMAGE_DATA_LIST__ = setImageDataList;
|
|
(window as any).__BOLT_UPLOADED_FILES__ = uploadedFiles;
|
|
(window as any).__BOLT_IMAGE_DATA_LIST__ = imageDataList;
|
|
}
|
|
|
|
return () => {
|
|
delete (window as any).__BOLT_SET_UPLOADED_FILES__;
|
|
delete (window as any).__BOLT_SET_IMAGE_DATA_LIST__;
|
|
delete (window as any).__BOLT_UPLOADED_FILES__;
|
|
delete (window as any).__BOLT_IMAGE_DATA_LIST__;
|
|
};
|
|
}, [setUploadedFiles, setImageDataList, uploadedFiles, imageDataList]);
|
|
|
|
return null;
|
|
};
|