Handle and control the current file path
mainThe FileManager starts at the root directory ("") by default. You can manage navigation using the following methods:
Set an initial path
Use the initialPath prop to specify the starting directory (e.g., /Documents). Note that initialPath is only applied once when the files state is first initialized.
Controlled path navigation
To track and control the current folder (e.g., to sync with your application's state), pair initialPath with the onFolderChange callback. This allows you to keep the path in sync with user navigation.
Important: After initialization, folder changes are driven by onFolderChange, not initialPath.
import { useState } from "react";
function App() {
const [currentPath, setCurrentPath] = useState("/Documents");
return (
<FileManager
// other props...
initialPath={currentPath}
onFolderChange={setCurrentPath}
/>
);
}