feat: update
Some checks are pending
Publish Any Commit / build (push) Waiting to run

This commit is contained in:
Wanpan 2025-06-04 17:53:32 +08:00
parent 54ecf918cb
commit f80bc646d9

View File

@ -3,7 +3,7 @@ import { Provider as MotionProvider } from 'rc-motion';
import { useToken } from '../theme/internal';
const MotionCacheContext = React.createContext({ parentMotion: true });
const MotionCacheContext = React.createContext(false);
if (process.env.NODE_ENV !== 'production') {
MotionCacheContext.displayName = 'MotionCacheContext';
}
@ -13,20 +13,22 @@ export interface MotionWrapperProps {
}
export default function MotionWrapper(props: MotionWrapperProps): React.ReactElement {
const { parentMotion } = React.useContext(MotionCacheContext);
const needWrapMotionProvider = React.useContext(MotionCacheContext);
const { children } = props;
const [, token] = useToken();
const { motion } = token;
let node = children as React.ReactElement;
if (parentMotion !== motion) {
node = <MotionProvider motion={motion}>{children}</MotionProvider>;
}
const needWrapMotionProviderRef = React.useRef(false);
needWrapMotionProviderRef.current = needWrapMotionProviderRef.current || motion === false;
if (needWrapMotionProviderRef.current || needWrapMotionProvider) {
return (
<MotionCacheContext.Provider value={{ parentMotion: motion }}>
{node}
<MotionCacheContext.Provider value={needWrapMotionProvider}>
<MotionProvider motion={motion}>{children}</MotionProvider>
</MotionCacheContext.Provider>
);
}
return children as React.ReactElement;
}