Skip to content

Commit

Permalink
fix: basic-layouts 组件销毁时清空defaultOpenKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenlingasMx committed Jun 25, 2023
1 parent b0dc65f commit 569e0fb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/basic-layouts/src/Sider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ const Sider = (props: SiderProps) => {
defultOpenMenus,
} = useLayouts();
const [defaultOpenKeys, setDefaultOpenKeys] = useState<string[]>([]);

useEffect(() => {
const keys = localStorage.getItem('defaultOpenKeys');
if (keys !== null) {
setDefaultOpenKeys(JSON.parse(keys));
}
return () => {
// 组件销毁时执行清空操作
setDefaultOpenKeys([]);
localStorage.removeItem('defaultOpenKeys');
};
}, []);

const collapsedView = useMemo(
Expand Down

0 comments on commit 569e0fb

Please sign in to comment.