question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not seem to fully support styled-components?

See original GitHub issue

I want to do this, passing the gatsby-image component `Img into a styled component, while animating it, like so:

const AnimatedImage = styled(motion(Img))`
  width: 200px;
  height: auto;
`

but this does not seem to work, giving me this error:

TypeError: Object(...) is not a function
Module.<anonymous>
src/pages/index.js:81
  78 |   }
  79 | `
  80 | 
> 81 | const LaxImg = styled(motion(Img))`
  82 |   width: 200px;
  83 |   height: auto;
  84 | `

it seems to work with regular html tags, just not react components, which is no bueno for me 😦

Am i doing something wrong? Is something like this not supported? It really needs to be supported, so hopefully I am doing something wrong or it’s on the way.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:25

github_iconTop GitHub Comments

21reactions
jacobgranberrycommented, Aug 7, 2019

Here’s an example of Styled Components working with motion.custom: https://codesandbox.io/s/framer-motion-with-styled-components-custom-components-i1wgk

I think I’m missing something - I don’t see any instance in this example of either a component made with styled components or a component using motion.custom

14reactions
rchrdnshcommented, Jul 13, 2019

just to be clear, this works fine in framer-motion:

const MotionDiv = styled(animated.div)`
  ...styles...
`

…without seemingly any issues, just not this:

const AnimatedReactComponent = styled(animated(ReactComponent))`
  ...styles...
`

…which would be lovely if it did 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQs - styled-components
Commonly asked questions about styled-components.
Read more >
Why styled-components is not styling the whole component?
and to check if it is working I painted text with color:red but it seems it is not working, no styles are being...
Read more >
How To Use Styled-Components In React - Smashing Magazine
If you look at the last example closely, you'll notice we didn't specify any HTML element to render. This is cool because we...
Read more >
The styled-components Happy Path - Josh W Comeau
styled -components is a wonderfully powerful styling library for React, ... is not meant to serve as an introduction to styled-components, ...
Read more >
Complete Guide On How To Use Styled-components In React
In Next.js, each page/component can have a dedicated style (CSS file). Conflicts do not exist because the styles from any CSS file will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found