Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'adaptViewConfig' of undefined #489

Open
rjuevesano opened this issue Nov 23, 2023 · 1 comment
Open

TypeError: Cannot read property 'adaptViewConfig' of undefined #489

rjuevesano opened this issue Nov 23, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rjuevesano
Copy link

I got this error and it crashes the app.

 ERROR  TypeError: Cannot read property 'adaptViewConfig' of undefined

This error is located at:
    in AnimatedComponent(View)
    in Unknown (created by BaseLayout)
    in BaseLayout
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by PanGestureHandler)
    in PanGestureHandler (created by IScrollViewGesture)
    in IScrollViewGesture
    in RNGestureHandlerRootView (created by GestureHandlerRootView)
    in GestureHandlerRootView
    in Unknown (created by RecipesScreen)
    in RCTView (created by View)
    in View
    in NativeWind.View
    in Unknown (created by RecipesScreen)
    in RCTView (created by View)
    in View
    in NativeWind.View
    in Unknown (created by RecipesScreen)
    in RCTView (created by View)
    in View (created by ScrollView)
    in RCTScrollView (created by ScrollView)
    in ScrollView (created by ScrollView)
    in ScrollView (created by RecipesScreen)
    in RCTView (created by View)
    in View
    in NativeWind.View
    in Unknown (created by Layout)
    in Layout (created by RecipesScreen)
    in RNGestureHandlerRootView (created by GestureHandlerRootView)
    in GestureHandlerRootView (created by RecipesScreen)
    in RecipesScreen (created by SceneView)
    in StaticContainer
    in EnsureSingleNavigator (created by SceneView)
    in SceneView (created by SceneView)
    in RCTView (created by View)
    in View (created by DebugContainer)
    in DebugContainer (created by MaybeNestedStack)
    in MaybeNestedStack (created by SceneView)
    in RCTView (created by View)
    in View (created by SceneView)
    in RNSScreen (created by AnimatedComponent)
    in AnimatedComponent
    in AnimatedComponentWrapper (created by InnerScreen)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by InnerScreen)
    in InnerScreen (created by Screen)
    in Screen (created by SceneView)
    in SceneView (created by NativeStackViewInner)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by ScreenStack)
    in RNSScreenStack (created by ScreenStack)
    in ScreenStack (created by NativeStackViewInner)
    in NativeStackViewInner (created by NativeStackView)
    in RCTView (created by View)
    in View (created by SafeAreaInsetsContext)
    in SafeAreaProviderCompat (created by NativeStackView)
    in NativeStackView (created by NativeStackNavigator)
    in PreventRemoveProvider (created by NavigationContent)
    in NavigationContent
    in Unknown (created by NativeStackNavigator)
    in NativeStackNavigator (created by MainNavigator)
    in MainNavigator (created by SceneView)
    in StaticContainer
    in EnsureSingleNavigator (created by SceneView)
    in SceneView (created by SceneView)
    in RCTView (created by View)
    in View (created by DebugContainer)
    in DebugContainer (created by MaybeNestedStack)
    in MaybeNestedStack (created by SceneView)
    in RCTView (created by View)
    in View (created by SceneView)
    in RNSScreen (created by AnimatedComponent)
    in AnimatedComponent
    in AnimatedComponentWrapper (created by InnerScreen)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by InnerScreen)
    in InnerScreen (created by Screen)
    in Screen (created by SceneView)
    in SceneView (created by NativeStackViewInner)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by ScreenStack)
    in RNSScreenStack (created by ScreenStack)
    in ScreenStack (created by NativeStackViewInner)
    in NativeStackViewInner (created by NativeStackView)
    in RCTView (created by View)
    in View (created by SafeAreaInsetsContext)
    in SafeAreaProviderCompat (created by NativeStackView)
    in NativeStackView (created by NativeStackNavigator)
    in PreventRemoveProvider (created by NavigationContent)
    in NavigationContent
    in Unknown (created by NativeStackNavigator)
    in NativeStackNavigator (created by Root)
    in Root (created by App)
    in RCTView (created by View)
    in View (created by MenuProvider)
    in RCTView (created by View)
    in View (created by MenuProvider)
    in MenuProvider (created by App)
    in AlertProvider (created by App)
    in ServiceProvider (created by App)
    in AuthProvider (created by App)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by App)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by App)
    in Unknown (created by App)
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in Qilo Health(RootComponent), js engine: hermes

Versions (please complete the following information):

  • react: v18.2.0
  • react-native: v0.71.8
  • react-native-reanimated: v3.5.1
  • react-native-reanimated-carousel: v3.5.1
  • react-native-gesture-handler: v2.10.0

** Here's my code

const itemSize = WINDOW_WIDTH / 2.2;
const centerOffset = WINDOW_WIDTH / 2;

const animationStyle = useCallback(
    (value: number) => {
      'worklet';

      const itemGap = interpolate(
        value,
        [-3, -2, -1, 0, 1, 2, 3],
        [-30, -15, 0, 0, 0, 15, 30],
      );

      const translateX =
        interpolate(value, [-1, 0, 1], [-itemSize, 0, itemSize]) +
        centerOffset -
        itemGap;

      const translateY = interpolate(
        value,
        [-1, -0.5, 0, 0.5, 1],
        [60, 45, 40, 45, 60],
      );

      const scale = interpolate(
        value,
        [-1, -0.5, 0, 0.5, 1],
        [0.8, 0.85, 1.1, 0.85, 0.8],
      );

      return {
        transform: [
          {
            translateX,
          },
          {
            translateY,
          },
          {scale},
        ],
      };
    },
    [centerOffset],
  );

<Carousel
                      ref={carouselRef}
                      style={{width: '100%'}}
                      width={WINDOW_WIDTH}
                      height={WINDOW_WIDTH / 1.75}
                      loop
                      autoPlay={false}
                      data={discoverRecipes}
                      scrollAnimationDuration={1000}
                      onSnapToItem={index => setDiscoverIndex(index)}
                      renderItem={({index}) => (
                        <View
                          key={index}
                          style={generateBorderStyle({shadow: true})}
                          className="h-[156px] w-[156px] items-center justify-center self-center rounded-full bg-white">
                          <Image
                            source={{
                              uri: discoverRecipes?.[index]?.images?.[0],
                            }}
                            className="h-[130px] w-[130px]"
                          />
                        </View>
                      )}
                      panGestureHandlerProps={{
                        activeOffsetX: [-10, 10],
                      }}
                      customAnimation={animationStyle}
                    />
@rjuevesano rjuevesano added the bug Something isn't working label Nov 23, 2023
@guillemsarda
Copy link

Hey!

I am probably late, but I have found a temporary solution to this problem in case you don't want/ can't update the library.

In my case the problem was derived from the fact that the initial list, that contained the animated items, was empty and after adding one element it crashed.

Therefore, what I did is to place a fallback array with a dummy element that is not going to be displayed.
Applying this logic to your code, it would look like this:

const carrouselList = discoverRecipes.length ? discoverRecipes : [{index: -1}] // fallback array

and the carrousel's data property would be:
<Carousel ... data={carrouselList} ... />

It is important that you handle the dummy variable in the array and do not display its content.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants