反应本机底部选项卡导航错误,来自 expo 模板的全新应用程序

React native bottom tab navigation error, brand new app from expo template

我刚刚使用 expo 模板创建了一个新应用程序,在不对代码进行任何更改的情况下执行时,它会抛出以下错误

    C02SW0WD:Projects user$ expo init testTabApp
? Choose a template: 
  ----- Managed workflow -----
  blank                 a minimal app as clean as an empty canvas 
  blank (TypeScript)    same as blank but with TypeScript configuration 
***❯ tabs                  several example screens and tabs using react-navigation*** 
  ----- Bare workflow -----
  minimal               bare and minimal, just the essentials to get you started 
  minimal (TypeScript)  same as minimal but with TypeScript configuration 

作为附加测试,我也使用 expo init 创建了一个黑色项目(空白 -> 一个像空一样干净的最小应用程序 canvas),该应用程序按预期工作......然后我添加了 bottom选项卡导航需要 npms:

  1. 纱线添加@react-navigation/native
  2. 纱线添加@react-navigation/bottom-tabs
  3. yarn 添加 react-native-screens
  4. yarn 添加 react-native-safe-area-context

之后,我创建了两个空白屏幕并修改了 App.js 以使用底部标签导航,如下所示:

import React from 'react';
import { Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Chat from './screens/Chat';
import Home from './screens/Home';

const Tab = createBottomTabNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Tab.Navigator>
        <Tab.Screen name="Home" component={Home} />
        <Tab.Screen name="Chat" component={Chat} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

再次出现关于 "undefined is not a function (near '...Object.fromEntries...')"

的相同错误

有什么想法吗??

更新:问题已在包中修复,更新到最新版本。 https://github.com/react-navigation/react-navigation/commit/51f4d11fdf4bd2bb06f8cd4094f051816590e62c

缺少方法 Object.fromEntries。 添加 yarn add @babel/polyfill 并更新您的 .babelrc 文件以使用它:

{
    "presets": [
        "module:metro-react-native-babel-preset",
        "@babel/polyfill"
    ]
}

之后应该可以使用,更多信息可在网站上找到 https://babeljs.io/docs/en/babel-polyfill