motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.66k stars 843 forks source link

Documentation wrongly suggests using motion.create for custom components #2796

Closed vincentreynaud closed 1 month ago

vincentreynaud commented 2 months ago

The current Framer documentation suggests to create custom components in the following way:

const Component = React.forwardRef((props, ref) => (
    <div ref={ref} />
))

const MotionComponent = motion.create(Component);

when in fact one should use this, at least for the latest packages.

const MotionComponent = motion(Component);

Took me a bit to find out after encountering a few stack overflow issues.

Please fix the docs of an otherwise amazing library 🙏

mattgperry commented 2 months ago

Did you try motion.create and it wasn't working?

vincentreynaud commented 1 month ago

Ok so I believe it was throwing an error in my gatsby app previously. Lost track of what changed so that it doesn't throw errors anymore, but i managed to make both work now. Sorry for the false alert.

manuelpoelzl commented 1 month ago

Just updated my modules and saw that the motion function no longer works, same goes for motion.create image

But this way I can not use the library anymore with 3rd party UI components, since I can not control how these components are structured. Seems like the only way to use framer with 3rd party UI components is to create a new component, which then renders the UI component from the framework right?