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.

After update v2: Value is undefined, expected an Object

See original GitHub issue

Description

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

https://user-images.githubusercontent.com/47625626/132988572-bcd72dbc-66b8-4dd9-a71f-a43d11517515.mp4

Actual behavior & steps to reproduce

https://user-images.githubusercontent.com/47625626/132989531-8e0e6638-4834-489b-8b75-59586e2a3d24.mp4

ScreenShot

Simulator Screen Shot - iPhone 11 - 2021-09-12 at 16 48 12

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:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
alakdam07commented, Oct 14, 2021

I am using React-native. I fixed the issue by using react-native-reanimated version 2.2.1. Also I wrote wrong code

0reactions
saberapcommented, Feb 18, 2022

This Problem solved for me by down gride to 2.2.1

Read more comments on GitHub >

github_iconTop 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 >

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