Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  169] [ 1]  / answers: 1 / hits: 8869  / 4 Years ago, thu, june 25, 2020, 12:00:00

I know that I can apply motion directly to element/HTMLtag like this:


<motion.div>some content</div>

But how can I apply it to this?


<Comp />

Without wrapping it inside another HTML element, like in React-Transition-Group library.


Framer API provides Frame component, but it acts like permanent additional HTML element with own styling, and it is messing my layout.


More From » reactjs

 Answers
3

If anyone comes to this page seeking for the solution of how to apply motion from Framer-Motion library to your React Component and not the direct DOM element like "div" or "span", here it is:


motion.custom()

Example of use:


import { Link } from "react-router-dom"

const MotionLink = motion.custom(Link)

return <MotionLink />

As for today it is not mentioned in the official documentation, or it is in someplace deep and hard to find.


I had found it in BUG reports here, there is a Codesanbox that illustrates my example, created by the person who reported a bug.


[#3375] Monday, June 22, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazminuniquer

Total Points: 63
Total Questions: 121
Total Answers: 96

Location: Cambodia
Member since Thu, May 21, 2020
4 Years ago
;