Error: [Reanimated] Reading from _value
directly is only possible on the UI runtime. Perhaps you passed an Animated Style to a non-animated component?
#6246
-
When I'm trying to use useAnimatedStyle in my component I facing this issue when its render. import { StyleSheet, View, ScrollView, Text, Pressable } from "react-native"; const TBAS = [ const AnimatedLinearGradient = Animated.createAnimatedComponent(LinearGradient); export default function HomeScreen() { const [layoutTop, setLayoutTop] = useState(0); const tabStyle = useAnimatedStyle(() => { return ( const styles = StyleSheet.create({ contentContainer: { |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey! Issue descriptionI looked into the Proposed solutionSolution 1 (easiest)In order to make it work, you can just wrap your <Animated.ScrollView
ref={animatedRef}
style={styles.scroll}
contentContainerStyle={styles.contentContainer}
stickyHeaderIndices={[1]} // <- you select the child at index 1 as a sticky header
>
<View style={styles.topContainer}></View>
<View> // <- you need to wrap this child with a plain View to prevent cloning of Animated.View
<Animated.View style={tabStyle}></Animated.View>
</View>
</Animated.ScrollView> In short, all components at indexes listed in the Solution 2You can write your custom StickyHeaderComponent that uses the |
Beta Was this translation helpful? Give feedback.
Hey!
Issue description
I looked into the
react-native
source code and the problem is caused by the fact thatreact-native
clones the child, which is used as a sticky-header in the default sticky header implementation (see this line of code). It looks that after cloning, theAnimated.View
no longer works and it works like a plainreact-native
View
component. Because this view is no longerAnimated.View
, the animated style that you correctly passed to theAnimated.View
is now passed to it's non-animated clone (plainView
), which results in the error that you can see.Proposed solution
Solution 1 (easiest)
In order to make it work, you can just wrap your
Animated.View
with the plainView
com…