After update v2: Value is undefined, expected an Object
See original GitHub issueDescription
Today we updated React-native-reanimated to ^2.2.1
. Add babel config plugins: plugins: ['react-native-reanimated/plugin']
. Removed Podfile.lock
then re-install pod. Test The Animated view but we are getting error: Value is undefined, expected an Object.
Expected behavior
Actual behavior & steps to reproduce
ScreenShot
Snack or minimal code example
import React from 'react';
import {
StyleSheet,
Text,
View,
Dimensions,
useWindowDimensions,
SafeAreaView,
} from 'react-native';
import MapView from 'react-native-maps';
import Animated, {
Extrapolate,
interpolate,
useAnimatedGestureHandler,
useAnimatedStyle,
withTiming,
useSharedValue,
} from 'react-native-reanimated';
import {
PanGestureHandler,
PanGestureHandlerGestureEvent,
} from 'react-native-gesture-handler';
type AnimatedGHContext = {
startX: number;
startY: number;
};
const { width } = Dimensions.get('screen');
const initialRegion = {
latitudeDelta: 15,
longitudeDelta: 15,
latitude: 60.1098678,
longitude: 24.7385084,
};
export default function App() {
const { height } = useWindowDimensions();
const panY = useSharedValue(0);
const gestureHandler = useAnimatedGestureHandler<
PanGestureHandlerGestureEvent,
AnimatedGHContext
>(
{
onStart(_, context) {
context.startY = panY.value;
},
onActive(event, context) {
panY.value = context.startY + event.translationY;
},
onEnd() {
if (panY.value < -height * 0.4) {
panY.value = withTiming(-(height * 0.6));
} else {
panY.value = withTiming(0);
}
},
},
[height],
);
const animatedStyle = useAnimatedStyle(() => {
return {
transform: [
{
translateY: interpolate(panY.value, [-1, 0], [-1, 0], {
extrapolateLeft: Extrapolate.EXTEND,
extrapolateRight: Extrapolate.CLAMP,
}),
},
],
};
});
return (
<View style={{ flex: 1 }}>
<MapView style={styles.mapStyle} initialRegion={initialRegion} />
<PanGestureHandler onGestureEvent={gestureHandler}>
<Animated.View
style={[styles.container, { top: height * 0.7 }, animatedStyle]}
>
<Animated.View style={styles.grbber} />
<SafeAreaView style={styles.wrapper}>
<View style={styles.content}>
<Text style={styles.title}>I am scroll sheet</Text>
<View style={styles.fakeContent} />
</View>
</SafeAreaView>
</Animated.View>
</PanGestureHandler>
</View>
);
}
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
backgroundColor: 'white',
shadowColor: 'black',
shadowOffset: {
height: -6,
width: 0,
},
shadowOpacity: 0.1,
shadowRadius: 5,
borderTopEndRadius: 15,
borderTopLeftRadius: 15,
},
mapStyle: {
width: width,
height: 800,
},
wrapper: {
flex: 1,
},
content: {
flex: 1,
padding: 20,
},
title: {
fontWeight: '400',
fontSize: 22,
},
fakeContent: {
flex: 1,
height: 1000,
},
grbber: {
width: 60,
alignSelf: 'center',
marginTop: 5,
borderTopWidth: 5,
borderTopColor: '#aaa',
},
});
Package versions
- Old React Native Reanimated: ^1.13.2
- React Native Reanimated: ^2.2.1
Affected platforms
- Android
- iOS
- Web
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
React Native render error Value is undefined expected a object
Update your react-native-reanimated version.In my case I have react-native-reanimated version 2.3.1 and rolling back to 2.2.4 version.After ...
Read more >Troubleshooting common problems | React Native Reanimated
TypeError: Cannot convert undefined value to object on someVariable._closure . This error frequently happens when metro cache is not updated.
Read more >undefined - JavaScript - MDN Web Docs - Mozilla
The global undefined property represents the primitive value undefined. It is one of JavaScript's primitive types.
Read more >React Native render error Value is undefined expected a ...
Related Query · React Native render error Value is undefined expected a object · React Native error: Element type is invalid: expected a...
Read more >Cannot convert undefined or null to Object in JavaScript
The "Cannot convert undefined or null to Object" error occurs when we pass a null or an undefined value to a function that...
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 Free
Top 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
I am using React-native. I fixed the issue by using react-native-reanimated version 2.2.1. Also I wrote wrong code
This Problem solved for me by down gride to 2.2.1