Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bottom-tabs: _reactNative.Animated[spec.animation] is not a function (it is undefined) #12789

Copy link
Copy link
@rigodamir

Description

@rigodamir
Issue body actions

Current behavior

I got this error on initialization while rendering bottom tabs

Image
import React, {useContext, useMemo} from 'react';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {defaultScreenOptions, ROUTES} from '.';
import {Image, View} from 'react-native';
import Colors from '../Utils/Colors';
import HomeStack from './HomeStack';
import ShopStack from './ShopStack';
import MyOrderStack from './MyOrdersStack';
import {OrderContext} from '../Providers/OrderProvider';
import {AuthContext} from '../Providers/AuthProvider';
import LoadingScreen from '../Screens/Main/LoadingScreen';
import Assets from '../../Assets';

const Tab = createBottomTabNavigator();

export default HomeBottomTabs = () => {
  const {currentOrder} = useContext(OrderContext);
  const {userAllData, askToSignIn} = useContext(AuthContext);
  const totalNumberOfITems = useMemo(
    () =>
      currentOrder.cart
        .filter(cartItem => cartItem.product.type !== 'woosb')
        .map(item => item.quantity)
        .reduce((p, c) => p + c, 0),
    [currentOrder],
  );

  const onTabPress = () => {
    return {
      tabPress: e => {
        if (!userAllData) {
          e.preventDefault();
          askToSignIn();
        }
      },
    };
  };

  const initialRouteName = useMemo(
    () =>
      currentOrder?.cart?.length > 0
        ? ROUTES.MAIN.SHOP.STACK
        : ROUTES.MAIN.HOME.STACK,
    [],
  );

  return (
    <View style={{flex: 1}}>
      {initialRouteName === ROUTES.MAIN.HOME.STACK && <LoadingScreen />}

      <Tab.Navigator
        initialRouteName={initialRouteName}
        screenOptions={{
          ...defaultScreenOptions,
          tabBarShowLabel: false,
          tabBarActiveTintColor: Colors.main_color,
          headerShown: false,
        }}>
        <Tab.Screen
          options={{
            tabBarIcon: HomeIcon,
          }}
          name={ROUTES.MAIN.HOME.STACK}
          component={HomeStack}
        />

        <Tab.Screen
          options={{
            tabBarBadge: totalNumberOfITems || null,
            tabBarIcon: ShopIcon,
          }}
          name={ROUTES.MAIN.SHOP.STACK}
          component={ShopStack}
        />

        <Tab.Screen
          listeners={onTabPress}
          options={{
            tabBarIcon: MyOrdersIcon,
          }}
          name={ROUTES.MAIN.MY_ORDERS.STACK}
          component={MyOrderStack}
        />
      </Tab.Navigator>
    </View>
  );
};

const NavIcon = ({iconColor, iconSource}) => (
  <Image
    source={iconSource}
    style={{width: 25, height: 25, resizeMode: 'contain', tintColor: iconColor}}
  />
);

const HomeIcon = ({color}) => (
  <NavIcon iconColor={color} iconSource={Assets.hut} />
);

const ShopIcon = ({color}) => (
  <NavIcon iconColor={color} iconSource={Assets.shopping} />
);

const MyOrdersIcon = ({color}) => (
  <NavIcon iconColor={color} iconSource={Assets.box} />
);

Expected behavior

I expected app to render properly bottom tabs

Reproduction

https://snack.expo.dev/@damirrigo/bottom-tabs-animated-error

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-drawer-layout
  • react-native-tab-view

Environment

  • [] I've removed the packages that I don't use
package version
@react-navigation/native 7.1.18
@react-navigation/bottom-tabs 7.4.8
@react-navigation/drawer 7.5.9
@react-navigation/material-top-tabs 7.3.8
@react-navigation/stack 7.4.9
react-native-tab-view 4.1.3
react-native-screens 4.16.0
react-native-safe-area-context 5.6.1
react-native-gesture-handler 2.28.0
react-native-reanimated 4.1.2
react-native-pager-view 6.9.1
react-native 0.81.4
react-native-drawer-layout 0.0.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.