-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX]: npx create-react-app my-app --template typescript Nested Folders Error #129
Comments
@mna-intend could you please share full code snippet so that I may debug the issue here. Also, what React version are you on ? |
here is the code:
|
@mna-intend I just tested your provided code and it's working fine. I'm using VID_20250114_011903.mp4App.tsx import React, { useState, useEffect } from 'react';
import { FileManager, File } from '@cubone/react-file-manager';
import '@cubone/react-file-manager/dist/style.css';
interface FileStorageViewComponentProps {
storageId?: string;
storagePath?: string;
}
const FileStorageViewComponent: React.FC<FileStorageViewComponentProps> = ({ storageId = '', storagePath = '/' }) => {
const [files, setFiles] = useState<File[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchFiles = async () => {
try {
const formattedFiles: File[] = [];
const test1: File =
{
isDirectory: true,
name: "folder1",
path: "/folder1",
size: 0,
updatedAt: "2025-01-07T08:42:48.333Z"
};
formattedFiles.push(test1);
const test: File =
{
isDirectory: true,
name: "folder2",
path: "/folder1/folder2",
size: 0,
updatedAt: "2025-01-07T08:42:48.333Z"
};
formattedFiles.push(test);
const test3: File =
{
isDirectory: false,
name: "t.png",
path: "/folder1/folder2/t.png",
size: 0,
updatedAt: "2025-01-07T08:42:48.333Z"
};
formattedFiles.push(test3);
setFiles(formattedFiles);
console.log('Formatted files:', formattedFiles);
} catch (error) {
console.error('Failed to fetch files:', error);
} finally {
setLoading(false);
}
};
fetchFiles();
}, [storageId, storagePath]);
const handleDownload = async (files: File[]) => {
};
const handleFileOpen = (file: File) => {
};
return (
<div>
{loading ?
<p>Loading...</p> :
<FileManager
files={files}
enableFilePreview={false}
onDownload={handleDownload}
onFileOpen={handleFileOpen}
/>
}
</div>
);
};
export default FileStorageViewComponent; cubone__react-file-manager.d.ts declare module '@cubone/react-file-manager' {
interface File {
name: string;
isDirectory: boolean;
path: string;
updatedAt: string;
size?: number;
}
interface FileManagerProps {
files: File[];
filePreviewPath?: string;
enableFilePreview?: boolean;
onDownload?: (files: File[]) => void;
onFileOpen?: (file: File) => void;
}
export const FileManager: React.FC<FileManagerProps>;
} |
@Saifullah-dev I placed it in the same folder as my The 'npm i --save-dev @types/cubone__react-file-manager' throws a http 404 error. |
@Saifullah-dev here is a more detailed error message from my project. Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of |
@Saifullah-dev After a day of debugging i still can't find the real problem. Your application uses something of I created a default project with |
@mna-intend I haven't t tried it with create- react-app. Will debug it and let you know. Thanks. |
@Saifullah-dev Thank you for your patience. Here is the simple repository with the error and my packages i use: react-file-manager-error |
You're getting PS. I'm troubleshooting |
I need many nested folders in folder, but i doesn't work properly. It gets me this error:
I am using Typescript.
The text was updated successfully, but these errors were encountered: