fix: console warning telling to update library

Massimo Melina committed Oct 2, 2023 at 15:22 UTC 53bfa27851419294e1a71fc818dbf144e67f3fe9
2 files changed +5 -2
admin/package.json
+1
@@ -16,6 +16,7 @@
16 "@mui/lab": "^5.0.0-alpha.142",
17 "@mui/material": "^5.14.8",
18 "@mui/x-data-grid": "^6.13.0",
19 + "@mui/x-tree-view": "^6.0.0-beta.0",
20 "@gregoranders/csv": "^0.0.12",
21 "react": "^18.2.0",
22 "react-dom": "^18.2.0",
admin/src/VfsTree.ts
+4 -2
@@ -2,7 +2,7 @@
2
3 import { state, useSnapState } from './state'
4 import { createElement as h, ReactElement, useRef, useState } from 'react'
5 -import { TreeItem, TreeView } from '@mui/lab'
5 +import { TreeItem, TreeView } from '@mui/x-tree-view'
6 import {
7 ChevronRight, ExpandMore, TheaterComedy, Folder, Home,
8 InsertDriveFileOutlined, Lock, RemoveRedEye, Web, Upload, Cloud, Delete, HighlightOff
@@ -21,11 +21,12 @@ export default function VfsTree({ id2node }:{ id2node: Map<string, VfsNode> }) {
21 const [selected, setSelected] = useState<string[]>(selectedFiles.map(x => x.id)) // try to restore selection after reload
22 const [expanded, setExpanded] = useState(Array.from(id2node.keys()))
23 const dragging = useRef<string>()
24 - const ref = useRef<HTMLElement>()
24 + const ref = useRef<HTMLUListElement>()
25 if (!vfs)
26 return null
27 const treeId = 'vfs'
28 return h(TreeView, {
29 + // @ts-ignore the type declared on the lib doesn't seem to be compatible with useRef()
30 ref,
31 expanded,
32 selected,
@@ -37,6 +38,7 @@ export default function VfsTree({ id2node }:{ id2node: Map<string, VfsNode> }) {
38 '& ul': { borderLeft: '1px dashed #444', marginLeft: '15px' },
39 },
40 onNodeSelect(ev, ids) {
41 + if (typeof ids === 'string') return // shut up ts
42 setSelected(ids)
43 state.selectedFiles = onlyTruthy(ids.map(id => id2node.get(id)))
44 }