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.

Invariant violation: `createAnimatedComponent` does not support stateless functional components

See original GitHub issue

I got this error when use createAnimatedComponent function.

steps:

create new expo typescript project install react-native-reanimated then use

code:


import React from "react";
import { StyleSheet, Text, View } from "react-native";
import Animated, { Easing } from "react-native-reanimated";

function Button() {
  return <View />;
}

const AnimButton = Animated.createAnimatedComponent(Button);

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.tsx to start working on your app!</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

deps:

"expo": "~36.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-reanimated": "^1.7.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "~0.11.7"

Simulator Screen Shot - iPhone X - 2020-02-01 at 21 27 24

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
joeyfigarocommented, Jul 5, 2020

@shamoons

class Button extends React.Component {
  render() {
    return <View />
  }
}
1reaction
Slapboxcommented, Sep 7, 2022

I don’t understand what findNodeHandle is. I guess it’s the native equivalent of findDOMNode, but outside of this warning caused by AnimatedComponent(View) I can’t find any reference to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I have a class Component but I get this ...
I have a class Component but I get this `createAnimatedComponent` does not support stateless functional components; use a class component ...
Read more >
Use Functional component as Animated Component - FyndX
In React Native at this moment Animated.createAnimatedComponent can be used only with class based components but not with functional components.
Read more >
use a class component instead-React Native - appsloveworld
[Solved]-I have a class Component but I get this `createAnimatedComponent` does not support stateless functional components; use a class component instead-React ...
Read more >
useAnimatedProps | React Native Reanimated
The animatedProps property is added when a native component is wrapped with Animated.createAnimatedComponent . If the animated props worklet uses any shared ...
Read more >
Move to functional components from the class components.
By using this Hook, we tell React that the component needs to do something after render. useEffect(() => { function handleStatusChange(status) {
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