来自世博网站

Expo让web开发者只需用JavaScript编写一次,就能构建出能够在iOS和Android上运行的真正原生应用。

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


当前回答

Expo and React Native are two popular tools for building mobile apps, but they have some differences. Expo is a free and open-source platform that allows developers to quickly build apps with JavaScript and React Native. It provides a set of tools, libraries, and services that make it easier to get started with building a mobile app. React Native, on the other hand, is a framework for building mobile apps using React. React Native provides a more direct way to access native APIs and components, and allows for more customization and control over the app development process. In summary, Expo provides a faster and easier way to get started with building a mobile app, while React Native provides more control and customization.

Another difference between Expo and React Native is the deployment process. With Expo, you can publish your app directly to the app stores with just a few clicks. You can also take advantage of other services that Expo provides, such as push notifications and authentication. On the other hand, when building a React Native app, you'll need to use tools like Xcode or Android Studio to compile and package the app for deployment. Additionally, you'll have to handle the distribution process yourself, which can be time-consuming and complex.

在性能方面,React Native通常比Expo有更好的性能,因为它可以直接访问本地api和组件,而Expo依赖于它的SDK。然而,在许多情况下,性能差异可能并不显著。

总之,Expo和React Native都有各自的优点和缺点,它们之间的选择取决于项目的具体需求和目标。如果你刚刚开始移动应用程序开发,想要一个快速简单的方法开始,Expo是一个很好的选择。然而,如果你想要更多的控制和定制,React Native可能是更好的选择。

其他回答

当你在Expo中编写代码时,你就是在编写React Native代码。世博会已经 两个主要部分:

Expo CLI (expo-cli): a developer tool for creating projects, viewing logs, opening on your device, publishing, etc. 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,就可以构建大多数应用程序,而不需要编写本地代码。

这一点很重要,因为使用React Native,你总是可以下拉到本地代码。这有时是非常有用的,但它是有代价的:如果你想让他们测试你的二进制文件,你需要把你的二进制文件发给他们,世界另一边的人不能在你工作的时候点击一个链接来打开它,你不能像在浏览器中那样一键发布它,让别人访问它。

对于Expo,我们建议尽量避免使用本地代码,如果可以的话。正如我上面提到的,我们认为JavaScript有了一套全面的api,对于大多数应用程序来说,这应该是不必要的。因此,我们的目标是提供这个全面的api集,然后构建所有可以存在于本机运行时共享世界中的强大工具。

但是,如果你必须发现你想要下拉到本地,你可以使用eject并继续使用Expo提供给你的本地api,同时拥有与任何本地项目相同的控制级别。

阅读更多关于弹射的内容

世博会CLI

优点:

无需安装Android Studio或Xcode即可开始构建。 不需要很多配置。 使用条形码扫描在Android和iPhone上轻松查看移动UI。通过在线iPhone和Android模拟器也更容易查看。 更快的设置和开发。

缺点:

无法添加本机依赖项。 创建。apk和。ipa文件是困难的。 apk/ipa的大小很大。

React Native CLI

优点:

轻松添加本机依赖项。 创建。apk和。ipa文件比使用Expo要容易得多

注意:React Native CLI是用来直接使用React Native框架的框架。

缺点:

需要高水平的配置。 基本了解Android和iOS文件夹结构。

如你所见,这两种方法各有利弊;您应该始终根据项目的需要来决定使用哪一种。

我在世博工作了一年多。 如果应用的大小对你来说不重要,使用Expo,因为它比React-native更容易实现Map和Push,但在项目结束时,如果你想在谷歌Play或其他商店发布应用,你会遇到一个挑战,删除APK中的一些权限。

在React Native中,你可以改变一切,但对于导入一些库,如推送通知或地图,它也需要一些挑战,因为你必须手动将这些库添加到Android和iOS项目中。

关于Expo和React Native CLI的优点和缺点的答案是完整的。我还想谈谈我的个人经历。

在项目中,默认情况下,Expo包含许多模块,这使得使用它更容易。但它在制作阶段存在一个大问题,因为Android和iOS版本的尺寸太大了。例如,如果你有一个带有“Hello, World!”’,APK文件大小约为19 MB。在React Native CLI中使用相同的项目将导致应用程序大小为6 MB。

所以就我个人而言,如果你想开发一款商业应用,我不建议你使用Expo。

这里我要说明的是,Expo使用的是React的旧版本16.5,这将禁止你使用新的hooks功能。

如果您决定使用Expo,请注意您的版本控制。例如,如果遇到奇怪的错误,就需要在16.5版本中使用旧版本的反应导航。