首页 > 解决方案 > 反应原生:有办法修复反应选项卡导航 5 中的错误“动画事件必须有事件数据”吗?

问题描述

每次移动选项卡时,我都会收到“动画事件必须有事件数据”错误,我真的不明白是什么原因造成的,为什么。我很乐意在这方面得到一些帮助。我创建了 3 个选项卡,每次在它们之间移动时都会出现此错误。我不知道如何解决它。这个错误的原因是什么?为什么会在我的情况下发生?

import React, { useState } from 'react';
import { Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import { useRoute, useNavigation } from '@react-navigation/native';

function NetuneyDigum() {
  return (
    <>
      <View
        style={{
          flex: 1,
          justifyContent: 'center',
          alignItems: 'center',
          backgroundColor: '#cbced4',
        }}
      >
        <Text>NetuneyDigum!</Text>
      </View>
    </>
  );
}

function BdikotSadea() {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#cbced4',
      }}
    >
      <Text>BdikotSadea!</Text>
    </View>
  );
}
function E_BitsuaDigdum() {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#cbced4',
      }}
    >
      <Text>E_BitsuaDigdum!</Text>
    </View>
  );
}

const Tab = createMaterialTopTabNavigator();

export default function Screen8() {
  const navigation = useNavigation();
  const route = useRoute();
  const params = route.params;
  const { item } = params;
  console.log('screen 8: ', params);
  return (
    <Tab.Navigator
      tabBarOptions={{
        activeTintColor: '#275d9f',
        inactiveTintColor: 'gray',
        indicatorStyle: {
          backgroundColor: 'red',
        },
        style: {
          //   backgroundColor: '#8bb8ef',
        },
        labelStyle: {
          fontSize: 18,
          fontWeight: 'bold',
         
        },
      }}
    >
      <Tab.Screen name="one" component={NetuneyDigum} />
      <Tab.Screen name="two" component={BdikotSadea} />
      <Tab.Screen name="three" component={E_BitsuaDigdum} />
    </Tab.Navigator>
  );
}

标签: javascriptreactjsreact-nativereact-reduxreact-native-navigation

解决方案


推荐阅读