#it's just a pattern, `withFoo(Bar)` is
1 messages · Page 1 of 1 (latest)
Hey, em I were thinking a bit about why it felt as a better in some cases.
So I heres an issue and response
https://github.com/framer/motion/issues/2054#issuecomment-1491568547
they suggested
"use client";
const MotionDiv = motion.div;
we of course instead can do
function MotionDiv({
children,
props
}: {
children: React.ReactNode,
props: [key:string]: any
}) {
return <motion.div {...props} >{children}<motion.div>;
}
But it is way longer
now
export const MotionDiv = withAnimationControllContext(motion.div);
I were having hard time to think of what is better this way, and there seems to be no difference.
But it feels for me that there is some advantage.
One way I would try to reason is that:
when we want to have a reactive context dependent components, we want create:
- a provider and a component that consumes a provider's context
But in this we create - a provider and a function to create a component that consumes that provider's context