TabNavigator 是否已弃用? [英] Is TabNavigator deprecated?

查看:68
本文介绍了TabNavigator 是否已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用...运行模拟器时

react-native run-ios

...我在终端中看到TabNavigator 已弃用"的消息.请使用 createBottomTabNavigator..."

但是,我不认为 TabNavigator 已被弃用,并且我不认为 createBottomTabNavigator 存在于网络上或现实中.除此之外,一切都好!除了我无法运行我的应用程序.因为我收到这个红屏错误,表明 React Navigation 有问题:

undefined 不是函数(靠近 '...(0 , _reactNavigation.TabNavigator)...')

附加上下文:这些问题是在我弹出 expo 应用程序,然后尝试通过创建新应用程序 (create-react-native-app) 将其重新构建为弹出前状态后开始出现的,然后移动我的自定义将代码从弹出之前的 git commit 写入新应用程序.我还必须更新模拟器中的 Expo 客户端.我不确定这是否是相关信息,但在我退出之前,我没有看到这条消息表明 TabNavigator 已被弃用.

React Navigation 文档没有表明 TabNavigator 可能会被弃用:

解决方案

TabNavigator 在 React Navigation 的 v1 中没有被弃用.但是,因为我像这样在 package.json 中引用了 react-navigation...

"react-navigation": "git+https://github.com/react-community/react-navigation.git",

我正在提取最新的代码,并且在某个时候(大概是昨天)这个参考开始提取 React Navigation 的 v2,而不是 v2,导致奇怪的已弃用"消息以及我的问题中提到的错误.

此处提供了解决方案:https://github.com/expo/expo/issues/1596#issuecomment-378424966

When I run the simulator with...

react-native run-ios

...I am seeing a message in the terminal that "TabNavigator is deprecated. Please use the createBottomTabNavigator..."

However, I don't think TabNavigator is deprecated, and I don't think createBottomTabNavigator exists on the web or in reality generally. Other than that, all's well! Except I can't run my app. Because I get this red-screen error suggesting something is amiss with React Navigation:

undefined is not a function (near '...(0 , _reactNavigation.TabNavigator)...')

Additional context: These issues began to appear after I ejected an expo app and then tried to re-constitute it in its pre-ejected state by creating a new app (create-react-native-app) and then moving my custom code into the new app, from a git commit prior to ejecting. I also had to update the Expo client in the simulator. I'm not sure if this is relevant info, but before I ejected, I did not see this message suggesting TabNavigator is deprecated.

The React Navigation docs give no indication that TabNavigator might be deprecated: https://reactnavigation.org/docs/tab-based-navigation.html

Here is the terminal output with a message indicating TabNavigator is deprecated:

解决方案

TabNavigator is not deprecated in v1 of React Navigation. However, because I referenced react-navigation in my package.json like this...

"react-navigation": "git+https://github.com/react-community/react-navigation.git",

I was pulling the latest code, and at some point (presumably yesterday) this reference started pulling in v2 of React Navigation, rather than v2, resulting in the strange "deprecated" message and also the error mentioned in my question.

The solution was provided here: https://github.com/expo/expo/issues/1596#issuecomment-378424966

这篇关于TabNavigator 是否已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆