反应本机底部标签导航错误,博览会模板中的全新应用

问题描述 投票:2回答:1

我刚刚使用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 

error detail without any change in code

作为另一项测试,我还使用expo init创建了一个黑色项目(空白->最小的应用程序,像空白画布一样干净,该应用程序按预期方式工作,然后我添加了底部选项卡导航,需要npms:

  1. yarn add @ react-navigation / native
  2. yarn add @ react-navigation / bottom-tabs
  3. 纱线添加react-native-screens
  4. 纱线添加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>
  );
}

再次,关于“未定义的错误不是函数('... Object.fromEntries ...'附近)”的错误]

任何思想家?

react-native expo react-native-navigation
1个回答
1
投票

更新:该问题已在软件包中修复,请将其更新为最新版本。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

© www.soinside.com 2019 - 2024. All rights reserved.