react-activation
react-activation copied to clipboard
在umi4中 使用 使用wrappers布局 缓存组件使用outlet 无法正常缓存,通过 getCachingNodes 只能获取一个节点
import { KeepAliveContainer } from '@/components/KeepAliveWrapper';
import { Outlet, useLocation } from '@umijs/max';
import { FC } from 'react';
const KeepAliveWrapper: FC = () => { const location = useLocation();
return ( <> <KeepAliveContainer name={location.pathname}> <Outlet /> </KeepAliveContainer> </> ); };
export default KeepAliveWrapper;
export const KeepAliveContainer = (props: any) => { return ( <> <KeepAlive name={props.name}>{props.children}</KeepAlive> </> ); };