“create-react-native-app myproject"之间的真正区别是什么?和“react-native init myproject" [英] whats the real diff between "create-react-native-app myproject" and "react-native init myproject"

查看:41
本文介绍了“create-react-native-app myproject"之间的真正区别是什么?和“react-native init myproject"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用本机和以下教程指南2 选项一是通过create-react-native-app myproject"创建项目,另一种是react-native init myproject".

I've recently started react native and following guide on tutorial there are 2 option one is create the project via "create-react-native-app myproject" and other one is "react-native init myproject".

第一个 (create-react-native-app) 只生成 app.js 而另一个生成 index.android.js 和 index.ios.js..

the first one(create-react-native-app) generates app.js only whereas other one generates index.android.js and index.ios.js..

我知道他们在做同样的工作,但真正的不同是什么?我应该选择哪一个开始,另一个何时更有用?

I know somehow they are doing same job but whats the real diffirence here ? which one should I pick to start and when the other one is more usefull over?

推荐答案

create-react-native-app ("CRNA") CLI 基于 Expo,一个第三方工具包,它允许您使用仅 JavaScript 编写跨平台 React Native 应用程序,并提供一个使应用程序在真实设备上运行的更流畅的工作流程.此外,Expo 提供了对大量本机 API 的访问,您可以为其通常需要库或自定义本机代码.

The create-react-native-app ("CRNA") CLI builds a project template based on Expo, a third-party toolkit which allows you to write cross-platform React Native applications using only JavaScript, and provides a smoother workflow for getting the app running on a real device. In addition, Expo provides access to tons of native APIs, for which you'd normally need libraries or custom native code.

Expo 很棒,在理想的世界中,它是大多数应用程序开发人员可能更喜欢使用的,但 Expo 的架构设置了一个不幸的限制:您无法编写自定义 Native Modules,或集成依赖于自定义的第三方库未构建到 Expo 中的本机代码.这意味着您只能访问 React Native 和 Expo 提供的原生功能,而无法轻松扩展它.

Expo is great, and in an ideal world, it is what most app developers would probably prefer to use, but Expo's architecture sets an unfortunate limitation: You cannot write custom Native Modules, or integrate third-party libraries which depend on custom native code that isn't build into Expo. This means you have only access to the native functionality provided by React Native and Expo, and cannot easily extend it.

相比之下,react-native CLI 的 init 命令创建了一个普通的 React Native 应用模板,您可以修改原生 iOS 和 Android 项目.这种方法的缺点是您需要在计算机上设置原生 iOS 和 Android 构建链,而且开始开发和部署应用程序要麻烦得多.

By contrast, the react-native CLI's init command creates a plain React Native app template, with native iOS and Android projects you can modify. The downside of this approach is that you'll need to set up the native iOS and Android build chains on your computer, and it's significantly more cumbersome to get started developing and deploying your app.

幸运的是,Expo 提供了一种方法来分离 CRNA 应用程序他们的原生应用程序外壳.这会将 CRNA 项目转换为类似于由 react-native init 创建的普通项目,但可以访问所有 Expo SDK 功能.

Luckily, Expo provides a way to detach a CRNA app from their native app shell. This will convert a CRNA project into something similar to the plain project created by react-native init, but with access to all the Expo SDK functionality.

在实践中,对于大多数初学者和新项目来说,最好的方法是从 create-react-native-app 开始,然后再评估是否需要分离.strong> Expo 提供了一个方便指南来提供帮助做出那个决定.

In practice, the best approach for most beginners and new projects is to start with create-react-native-app, and evaluate whether you'll need to detach later. Expo provides a handy guide to help making that decision.

这篇关于“create-react-native-app myproject"之间的真正区别是什么?和“react-native init myproject"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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