diff --git a/src/TreeView/TreeView.tsx b/src/TreeView/TreeView.tsx index 4d53f0e669b..669f1d24364 100644 --- a/src/TreeView/TreeView.tsx +++ b/src/TreeView/TreeView.tsx @@ -30,7 +30,7 @@ const RootContext = React.createContext<{ // We cache the expanded state of tree items so we can preserve the state // across remounts. This is necessary because we unmount tree items // when their parent is collapsed. - expandedStateCache: React.RefObject> + expandedStateCache: React.RefObject | null> }>({ announceUpdate: () => {}, expandedStateCache: {current: new Map()} @@ -261,13 +261,13 @@ const Root: React.FC = ({'aria-label': ariaLabel, 'aria-labelledb } } }) - - const expandedStateCache = React.useRef(null) + + const expandedStateCache = React.useRef | null>(null) if (expandedStateCache.current === null) { - expandedStateCache.current = new Map(); + expandedStateCache.current = new Map() } - + return (