Skip to content

Commit

Permalink
fix: delcare the useEffect before return (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor authored Sep 29, 2022
1 parent 219b937 commit 3b73285
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/workbench/sidebar/explore/folderTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,6 @@ const FolderTree: React.FunctionComponent<IFolderTreeProps> = (props) => {
current,
} = folderTree;

const handleAddRootFolder = () => {
createTreeNode?.('RootFolder');
};

const welcomePage = (
<div data-content={panel.id}>
{entry ? (
<>{entry}</>
) : (
<div style={{ padding: '10px 5px' }}>
you have not yet opened a folder
<Button onClick={handleAddRootFolder}>Add Folder</Button>
</div>
)}
</div>
);

if (!data.length) return welcomePage;

const inputRef = useRef<HTMLInputElement>(null);
// tree context view
const contextMenu = useRef<ReturnType<typeof useContextMenu>>();
Expand Down Expand Up @@ -221,6 +202,10 @@ const FolderTree: React.FunctionComponent<IFolderTreeProps> = (props) => {
onDropTree?.(source, target);
};

const handleAddRootFolder = () => {
createTreeNode?.('RootFolder');
};

useEffect(() => {
if (folderPanelContextMenu.length > 0) {
contextMenu.current = initContextMenu();
Expand All @@ -230,6 +215,21 @@ const FolderTree: React.FunctionComponent<IFolderTreeProps> = (props) => {
};
}, [data.length]);

const welcomePage = (
<div data-content={panel.id}>
{entry ? (
<>{entry}</>
) : (
<div style={{ padding: '10px 5px' }}>
you have not yet opened a folder
<Button onClick={handleAddRootFolder}>Add Folder</Button>
</div>
)}
</div>
);

if (!data.length) return welcomePage;

return (
<Scrollable noScrollX isShowShadow>
<div data-content={panel.id} style={{ height: '100%' }}>
Expand Down

0 comments on commit 3b73285

Please sign in to comment.