React Native指南

蓬英逸
2023-12-01

React本机 (React Native)

React Native is a cross-platform framework for building mobile applications that can run outside of the browser — most commonly iOS and Android applications

React Native是一个跨平台框架,用于构建可在浏览器外部运行的移动应用程序-最常见的iOS和Android应用程序

It can be used to build applications on Windows devices, desktop OS’s, and Apple TV apps as well but this guide will only be covering its most common purpose — Android and iOS applications.

它也可以用于在Windows设备,台式机操作系统和Apple TV应用程序上构建应用程序,但本指南仅涵盖其最常见的用途-Android和iOS应用程序。

Table of Contents

目录

什么是React Native? (What is React Native?)

React Native falls in-between native and hybrid applications on the mobile app spectrum. The user interface you create is entirely native and the overall application performance is nearly as good as writing a native app.

在移动应用程序范围内,React Native介于本地应用程序和混合应用程序之间。 您创建的用户界面完全是本机的,整体应用程序性能几乎与编写本机应用程序一样好。

It also gives you the flexibility to embed web views (webpages) or native code (Java/Kotlin for Android, Objective C/Swift for iOS) inside your applications wherever you want.

它还使您可以灵活地将Web视图(网页)或本机代码(Android的Java / Kotlin,iOS的Objective C / Swift)嵌入到所需的位置。

It follows the same pattern as React where the views (what you see on the screen) are rendered from the JavaScript files. The difference is that it supplies its own API for handling native mobile views vs the DOM on the web.

它遵循与React相同的模式,其中从JavaScript文件渲染视图(在屏幕上看到的内容)。 不同之处在于,它提供了自己的API来处理本机移动视图,而不是Web上的DOM。

If you are confused about how this works, follow this guide on freeCodeCamp and it will take you step by step through these concepts.

如果您对它的工作方式感到困惑,请遵循freeCodeCamp上的本指南,它将逐步引导您了解这些概念。

选择React Native的理由 (Reasons to choose React Native)

  1. Code reusability — It uses one code based that is shared between both platforms.

    代码可重用性 -它使用一种基于代码的代码,在两个平台之间共享。

  2. Reuse web tools and skills — Reuse JavaScript knowledge, tools and utilities like axios, Redux, and other libraries that don’t require the DOM from the web.

    重用Web工具和技能 -重用JavaScript知识,工具和实用程序,例如axios ,Redux和其他不需要Web DOM的库。

  3. Optimized for developer productivity — Comes with features like hot/live module reloading and chrome developer tools for debugging out of the box!

    针对开发人员的生产力进行了优化 -带有热/实时模块重新加载功能以及用于调试的chrome开发人员工具等功能!

  4. Performance — Performs better than hybrid application frameworks like Ionic and Cordova since it is not using web views.

    性能 —由于未使用Web视图,因此其性能比Ionic和Cordova等混合应用程序框架更好。

  5. Corporate backing — Lots of companies support and contribute to React Native including Walmart, Airbnb, Wix, and, of course, Facebook.

    企业支持 -许多公司支持和贡献React Native,包括沃尔玛,Airbnb,Wix,当然还有Facebook。

  6. Community — React Native has a large (and growing) community with over 1500 contributors to the core project and thousands more who contribute to various libraries.

    社区 -React Native拥有一个庞大的社区(并且正在不断发展),该社区有1500多个贡献者为核心项目,成千上万的人为各种图书馆做出了贡献。

  7. Better user experience — React Native uses the JavaScript code to render native components from your phone’s OS. In other words, the application’s user interface (UI) is entirely native!

    更好的用户体验 -React Native使用JavaScript代码从手机的操作系统渲染本机组件。 换句话说,应用程序的用户界面(UI)完全是本机的!

  8. Cross-Platform - Great way to prototype and save time while building either a universal user interface or platform specific mobile application that can run on both iOS and Android devices.

    跨平台 -在构建可在iOS和Android设备上运行的通用用户界面或特定于平台的移动应用程序时,实现原型和节省时间的好方法。

如何开始使用React Native (How to Get Started with React Native)

There are two quick easy ways to get started with React Native. Depending on your situation, one can be a better option for you.

有两种快速简便的方法可以开始使用React Native。 根据您的情况,一个可能是您更好的选择。

  1. Create React Native App- Similar to Create React App, it gets up and running using the terminal.

    创建React Native应用程序 -与创建React App类似,它使用终端启动并运行。

  2. Expo - Best for prototyping an app or if it is earlier stage. Using Expo you can even create a quick app using drag and drop features from snack.expo.io in the browser.

    博览会 -最适合制作应用原型或处于早期阶段的原型。 使用Expo,您甚至可以使用浏览器中Snack.expo.io的拖放功能来创建快速应用程序。

关于React Native的更多资源: (More resources on React Native:)

翻译自: https://www.freecodecamp.org/news/react-native-guide/

 类似资料: