Expo 和 React Native 有什么区别? [英] What is the difference between Expo and React Native?

查看:137
本文介绍了Expo 和 React Native 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自世博会网站

Expo 让网络开发者只需用 JavaScript 编写一次即可构建真正适用于 iOS 和 Android 的原生应用.

Expo lets web developers build truly native apps that work across both iOS and Android by writing them once in just JavaScript.

这不是 React Native 所做的吗?有什么区别?

Isn't this what React Native does? What's the difference?

推荐答案

当您在 Expo 中编写代码时,您就是在编写 React Native 代码.世博有两个主要部分:

When you write code in Expo you are writing React Native code. Expo has two main pieces:

  1. Expo CLI (expo-cli):用于创建项目、查看日志、在您的设备上打开、发布等的开发者工具.

  1. Expo CLI (expo-cli): a developer tool for creating projects, viewing logs, opening on your device, publishing, etc.

Expo 客户端:手机上的应用程序,可让您打开项目当您在处理它们时,无需通过 XCode 或 Android Studio,也可以让其他人查看它们!如果您通过 expo-cli 发布它,人们可以随时通过 Android 或 iOS 上的 Expo 客户端访问它,前提是登录到发布时使用的同一帐户.最后,我们还可以构建独立的应用程序,这样人们就不必使用 Expo 客户端来打开它,并且您可以根据需要分发到应用程序商店和 Play 商店.

Expo client: an app on your phone that lets you open your projects while you're working on them, without needing to go through XCode or Android Studio, and also lets other people view them too! And if you publish it through expo-cli, people can access it at any time through the Expo client on Android or on iOS if signed in to the same account it was published with. Lastly, we also make it possible to build standalone apps so people don't have to use the Expo client to open it, and you can distribute to the app store and play store if you like.

所以 Expo 是一套建立在 React Native 之上的工具.这些工具依赖于 Expo 的一个关键信念:无需编写本机代码即可构建大多数应用程序,前提是您拥有一组全面的面向 JavaScript 的 API.

So Expo is a set of tools built on top of React Native. These tools depend on one key belief held at Expo: it's possible to build most apps without ever needing to write native code, provided that you have a comprehensive set of APIs exposed to JavaScript.

这很重要,因为使用 React Native,您始终可以下拉到本机代码.这有时非常有用,但它是有代价的:如果你想让他们测试你的二进制文件,你需要向他们发送二进制文件,世界另一端的人不能在你工作时点击链接打开它在它上面,你不能像在浏览器中那样,一键发布它供他人访问.

This is important because with React Native you can always drop down to native code. This is incredibly helpful sometimes but it comes at a cost: you need to send people your binaries if you want them to test them, someone on the other side of the world can't just tap a link to open it while you're working on it and you can't just publish it with one click for someone to access it similar to how you would in a browser.

对于 Expo,我们建议尽可能避免使用原生代码.正如我上面提到的,我们认为有了一组全面的可用于 JavaScript 的 API,这对于大多数应用程序来说应该不是必需的.因此,我们的目标是提供这套全面的 API,然后构建所有可存在于共享本机运行时的世界中的出色工具.

With Expo, we suggest that try to avoid dropping down to native code, if you can. As I mentioned above, we think that with a comprehensive set of APIs available to JavaScript, this shouldn't be necessary for most apps. So, we aim to provide this comprehensive set of APIs, and then build all of the awesome tooling that can exist in a world where the native runtime is shared.

但是,如果您必须发现自己想要降级到原生,您可以使用弹出并继续使用 Expo 为您提供的原生 API,同时拥有与在任何原生项目中相同的控制级别.

However, if you must find that you want to drop down to native, you can use eject and continue using the native APIs that Expo gives you while having the same level of control as you would in any native project.

阅读有关弹出的更多信息

这篇关于Expo 和 React Native 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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