Using Animated with styled-components (react-native) Using Animated with styled-components (react-native) reactjs reactjs

Using Animated with styled-components (react-native)


This issue is actually not related to styled-components. Rather, it's a react-native one

The workaround for this is to use class instead of a stateless component.

class Logo extends React.Component {  render () {    return (      <SLogoImage        source={require('./geofence.gif')}        {...this.props}      />    )  }}

Here is a github repo where it is working. If anyone wants to reproduce it, Just uncomment 14-21 lines to see the error.

I think the issue comes from Animated trying to attach ref to a stateless component. And stateless components cannot have refs.