We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 64085c4 commit 634cdf2Copy full SHA for 634cdf2
1 file changed
src/context.tsx
@@ -6,9 +6,16 @@ interface MotionContextProps {
6
7
export const Context = React.createContext<MotionContextProps>({});
8
9
-export default function MotionProvider({
10
- children,
11
- ...props
12
-}: MotionContextProps & { children?: React.ReactNode }) {
13
- return <Context.Provider value={props}>{children}</Context.Provider>;
14
-}
+const MotionProvider: React.FC<
+ React.PropsWithChildren<MotionContextProps>
+> = props => {
+ const { children, ...rest } = props;
+
+ const memoizedValue = React.useMemo<MotionContextProps>(() => {
15
+ return { motion: rest.motion };
16
+ }, [rest.motion]);
17
18
+ return <Context.Provider value={memoizedValue}>{children}</Context.Provider>;
19
+};
20
21
+export default MotionProvider;
0 commit comments