Fix: 사이드바 에러 해결

This commit is contained in:
정현조 2024-10-04 10:03:39 +09:00
parent cee46f5605
commit b02cc20db6

View File

@ -28,7 +28,7 @@ const ItemTypes = {
}; };
export default function ProjectStructure({ project }: { project: Project }) { export default function ProjectStructure({ project }: { project: Project }) {
const { setProject, setCategories, folderId, setFolderId } = useProjectStore(); const { setProject, setCategories, setFolderId } = useProjectStore();
const { image: selectedImage, setImage } = useCanvasStore(); const { image: selectedImage, setImage } = useCanvasStore();
const { treeData, fetchNodeData, setTreeData } = useTreeData(project.id.toString()); const { treeData, fetchNodeData, setTreeData } = useTreeData(project.id.toString());
const { data: categories } = useProjectCategoriesQuery(project.id); const { data: categories } = useProjectCategoriesQuery(project.id);
@ -40,24 +40,20 @@ export default function ProjectStructure({ project }: { project: Project }) {
const [containerHeight, setContainerHeight] = useState<number>(400); const [containerHeight, setContainerHeight] = useState<number>(400);
useEffect(() => { useEffect(() => {
setCategories(categories); if (categories) {
setCategories(categories);
}
}, [categories, setCategories]); }, [categories, setCategories]);
useEffect(() => { useEffect(() => {
setProject(project); setProject(project);
}, [project, setProject]); }, [project, setProject]);
useEffect(() => {
if (treeData) {
setFolderId(folderId);
}
}, [treeData, setFolderId, folderId]);
useEffect(() => { useEffect(() => {
if (containerRef.current) { if (containerRef.current) {
setContainerHeight(containerRef.current.clientHeight); setContainerHeight(containerRef.current.clientHeight);
} }
}, [containerRef, treeData, isLoading]); }, [treeData, isLoading]);
const onToggle = useCallback( const onToggle = useCallback(
async (node: TreeNode, toggled: boolean) => { async (node: TreeNode, toggled: boolean) => {