React Native:我应该使用哪个导航器? [英] React Native: Which navigator should I use?

查看:152
本文介绍了React Native:我应该使用哪个导航器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在3个月内构建一个相对较大的跨平台(iOS和Android)应用程序.

I have to build a relatively big cross-platform (iOS & Android) application within 3 months.

到目前为止,关于React Native,我只有NavigatorIOS的经验.现在,尽管我从未真正遇到任何问题,但从未见过有人推荐使用它.

So far when it comes to React Native I only have experience with NavigatorIOS. Now while I never really ran into any problems with it I never see people recommending its use.

其他选项是Navigator,它看起来很简单,但是可能并没有太多的本机UI支持?和NavigatorExperimental,我一无所知,仅这个名字就让我担心.我不想做最后一刻的噩梦.

The other options are Navigator, which seems simple enough but maybe doesn't allow much native UI support? and NavigatorExperimental which I know nothing of, and the name alone worries me. I don't want to be having any last minute nightmares.

我计划花一个月的时间全面学习React Native,然后花两个月的时间构建应用程序.

I plan on spending a month learning React Native thoroughly and then 2 months building the application.

这引出我的问题:如果您必须在React Native中构建跨平台应用程序,那么您将在每个平台上使用哪种导航,为什么?

This leads me to my question: If you had to build a cross platform application in React Native, which navigation would you use for each platform, and why?

任何答案或提示都将不胜感激.

Any answers or tips greatly appreciated.

推荐答案

回答了我自己的问题,因为我对现有的各种选择进行了大量研究,并亲自尝试了所有主要选择.

Answering my own question as I've done quite a bit of research on the different options out there, and tried all the main ones out myself.

新编辑:从今天开始(2020年7月),我建议使用 React Navigation v5 .这是Facebook最推崇的社区解决方案. V5重写是一个完整的游戏规则改变者,它远远优于以前的版本.在大多数情况下,易于设置和实现简单/复杂的堆栈是一件轻而易举的事.

NEW As of today (07/2020) I suggest using React Navigation v5. It's the community solution being most pushed by Facebook. The V5 rewrite was a complete game changer and is far superior to previous versions. Easy to get setup and implementing easy/complicated stacks is a breeze most of the time.

如果那不是为您做的,另一种选择是 react-native-navigation 通过wix(不幸的是与博览会不兼容).

If that's not doing it for you another alternative is react-native-navigation by wix (not compatible with expo unfortunately).

请关注airbnb的原生导航.他们已经处于测试阶段了一段时间,并且最近没有被大量推入该项目,因此我仍然建议将React Navigation用于产品. (避免-此项目已已删除.)

Keep an eye on native-nagivation by airbnb. They've been in beta for a while and not much has been pushed to the project recently so I'd still suggest React Navigation for prod. (edit: avoid - this project has been dropped.)

以下原始帖子:

TLDR:截至今天(2017年1月13日),我仍然强烈建议对本机路由器流量进行反应.通过 ex-navigation rel ="nofollow noreferrer">指数是一个很好的选择.

TLDR: As of today (13/01/2017) I would still highly suggest React Native Router Flux. With ex-navigation, by Exponent being a great alternative.

我一直在为项目使用RNRF,到目前为止,它是完美的.一流的导航栏堆栈自定义(这对我来说是一件大事),并且易于与其他软件包集成.

I have been using RNRF for my project and it's been perfect so far. Superb navbar & stack customization (which was a big thing for me) and easy to integrate with other packages.

长版:(现在已过期)

导航器:要避免.在我不作任何详细说明的情况下,Facebook放弃了它并不再对其进行维护的事实对我来说是一个足够大的理由选择另一个导航.

Navigator: To be avoided. Without going into details why, the fact that Facebook have dropped it and are no longer maintaining it is to me, a big enough reason to choose another navigation.

NavigatorIOS :顾名思义,仅在IOS上可用,如果您要使用跨平台应用程序,那不是很好.在堆叠方面,有几个区别对我来说胜过整个 FB要做的事情. 话虽如此,如果您的iOS应用导航不太复杂,并且您不需要太多导航栏自定义设置,那么这是一个不错的选择,它利用了本机UIKit导航功能,因此会自动呈现一个带有后退按钮和标题的导航栏.

NavigatorIOS: As the name states, only available on IOS, which isn't great if you're going for a cross-platform application. There are a couple of difference when it comes to stacking which to me, beats the whole 'learn once, write anywhere' thing FB are going for. With that said, if your iOS app's navigation isn't too complicated, and you're not looking for too much navbar customisation this is a fairly good choice which leverages native UIKit navigation, so will automatically render a navigation bar with a back button and title.

NavigationExperimental :请不要害怕就像我以前一样的名字. NavigationExperimental具有对导航堆栈的大量控制,并允许更加轻松的状态管理.不包括第三方库,这是转到导航选项.

NavigationExperimental: Don't be scared off by it's name like I was. NavigationExperimental has lots of control over the navigation stack, and allows for much easier state management. Excluding 3rd party libraries, this is to go to navigation option.

前导航:我只引用Facebook的Eric Vicenti, React Native团队:

Ex-Navigation: I'll just quote Eric Vicenti of Facebook, who's on the React Native team:

如果您对一种更必要的方法感兴趣,可以在 某种make方法调用,用于在整个应用程序中导航 与以前的导航器类似,那么我肯定会 建议使用ExNavigation.我们正在与指数公司紧密合作 因此这些事情不会以危险的方式发生分歧.

If you are interested in a more imperative approach, where you can sort of make method calls to navigate throughout your application in a way similar to the previous Navigator, then I would definitely recommend ExNavigation. We’re working relatively closely with Exponent so these things are not going to sort of diverge in dangerous ways.

反应路由器原生:文档说明了一切.我只能说,如果您习惯了React Router,这可能适合您.

React Router Native: The docs say it all. All I can say is if you're used to React Router, this could be for you.

请关注:通过WIX进行本机导航.看起来非常不错,但由于它在

Keep an eye on: React Native Navigation by WIX. Looks very decent but I haven't given it a go given the fact it's a bit behind the latest version of react native (when writing this answer).

有趣的RN Nav读取:

Interesting RN Nav reads:

React Native —哪个导航器我应该使用吗?

第一眼:React Native Navigator实验性第1部分

这篇关于React Native:我应该使用哪个导航器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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