From 5f506996b4b7e222af6fd7a849a8c7f323f4fe36 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Tue, 3 Feb 2026 23:39:53 +0800 Subject: [PATCH] refactor(context): memoize provider value --- src/context.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/context.tsx b/src/context.tsx index 937bb75..970867e 100644 --- a/src/context.tsx +++ b/src/context.tsx @@ -6,9 +6,16 @@ interface MotionContextProps { export const Context = React.createContext({}); -export default function MotionProvider({ - children, - ...props -}: MotionContextProps & { children?: React.ReactNode }) { - return {children}; -} +const MotionProvider: React.FC< + React.PropsWithChildren +> = props => { + const { children, ...rest } = props; + + const memoizedValue = React.useMemo(() => { + return { motion: rest.motion }; + }, [rest.motion]); + + return {children}; +}; + +export default MotionProvider;