Invariant violation: `createAnimatedComponent` does not support stateless functional components
See original GitHub issueI 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"
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shamoons
I don’t understand what
findNodeHandle
is. I guess it’s the native equivalent offindDOMNode
, but outside of this warning caused byAnimatedComponent(View)
I can’t find any reference to it.