• c9_450041
  • 111KB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-04-29 07:01
该项目是通过。 您将在下面找到有关执行常见任务的信息。 本指南的最新版本可。 目录 构建世博会的“独立”应用 从Create React Native App弹出 构建依赖关系(Xcode和Android Studio) 我应该使用ExpoKit吗? 故障排除 联网 iOS模拟器无法打开 QR码不扫描 更新到新版本 您只需要很少(理想情况下永远不需要)更新全局安装的create-react-native-app 。 更新应用程序的react-native-scripts依赖性应该很简单,只需增加package.json的版本号并重新安装项目的依赖性即可。 升级到React Native的新版本需要更新react-native , react和expo软件包版本,并在app.json设置正确的sdkVersion 。 有关软件包版本兼容性的最新信息,请参见版本控制指南。 可用脚
  • vjobs-reactnative-master
  • Components
  • Screens
  • HomeScreen.js
  • DetailScreen.js
  • Navigation
  • Navigation.js
  • assets
  • logo-h-vjobs.png
  • Networking
  • API.js
  • .babelrc
  • App.js
  • README.md
  • App.test.js
  • app.json
  • .gitignore
  • .watchmanconfig
  • package-lock.json
  • package.json
This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app). Below you'll find information about performing common tasks. The most recent version of this guide is available [here](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md). ## Table of Contents * [Updating to New Releases](#updating-to-new-releases) * [Available Scripts](#available-scripts) * [npm start](#npm-start) * [npm test](#npm-test) * [npm run ios](#npm-run-ios) * [npm run android](#npm-run-android) * [npm run eject](#npm-run-eject) * [Writing and Running Tests](#writing-and-running-tests) * [Environment Variables](#environment-variables) * [Configuring Packager IP Address](#configuring-packager-ip-address) * [Customizing App Display Name and Icon](#customizing-app-display-name-and-icon) * [Sharing and Deployment](#sharing-and-deployment) * [Publishing to Expo's React Native Community](#publishing-to-expos-react-native-community) * [Building an Expo "standalone" app](#building-an-expo-standalone-app) * [Ejecting from Create React Native App](#ejecting-from-create-react-native-app) * [Build Dependencies (Xcode & Android Studio)](#build-dependencies-xcode-android-studio) * [Should I Use ExpoKit?](#should-i-use-expokit) * [Troubleshooting](#troubleshooting) * [Networking](#networking) * [iOS Simulator won't open](#ios-simulator-wont-open) * [QR Code does not scan](#qr-code-does-not-scan) ## Updating to New Releases You should only need to update the global installation of `create-react-native-app` very rarely, ideally never. Updating the `react-native-scripts` dependency of your app should be as simple as bumping the version number in `package.json` and reinstalling your project's dependencies. Upgrading to a new version of React Native requires updating the `react-native`, `react`, and `expo` package versions, and setting the correct `sdkVersion` in `app.json`. See the [versioning guide](https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md) for up-to-date information about package version compatibility. ## Available Scripts If Yarn was installed when the project was initialized, then dependencies will have been installed via Yarn, and you should probably use it to run these commands as well. Unlike dependency installation, command running syntax is identical for Yarn and NPM at the time of this writing. ### `npm start` Runs your app in development mode. Open it in the [Expo app](https://expo.io) on your phone to view it. It will reload if you save edits to your files, and you will see build errors and logs in the terminal. Sometimes you may need to reset or clear the React Native packager's cache. To do so, you can pass the `--reset-cache` flag to the start script: ``` npm start --reset-cache # or yarn start --reset-cache ``` #### `npm test` Runs the [jest](https://github.com/facebook/jest) test runner on your tests. #### `npm run ios` Like `npm start`, but also attempts to open your app in the iOS Simulator if you're on a Mac and have it installed. #### `npm run android` Like `npm start`, but also attempts to open your app on a connected Android device or emulator. Requires an installation of Android build tools (see [React Native docs](https://facebook.github.io/react-native/docs/getting-started.html) for detailed setup). We also recommend installing Genymotion as your Android emulator. Once you've finished setting up the native build environment, there are two options for making the right copy of `adb` available to Create React Native App: ##### Using Android Studio's `adb` 1. Make sure that you can run adb from your terminal. 2. Open Genymotion and navigate to `Settings -> ADB`. Select “Use custom Android SDK tools” and update with your [Android SDK directory](https://stackoverflow.com/questions/25176594/android-sdk-location). ##### Using Genymotion's `adb` 1. Find Genymotion’s copy of adb. On macOS for example, this is normally `/Applications/Genymotion.app/Contents/MacOS/tools/`. 2. Add the Genymotion tools directory to your path (instructions for [Mac](http://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/), [Linux](http://www.computerhope.com/issues/ch001647.htm), and [Windows](https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/)). 3. Make sure that you can run adb from your terminal. #### `npm run eject` This will start the process of "ejecting" from Create React Native App's build scripts. You'll be asked a couple of questions about how you'd like to build your project. **Warning:** Running eject is a permanent action (aside from whatever version control system you use). An ejected app will require you to have an [Xcode and/or Android Studio environment](https://facebook.github.io/react-native/docs/getting-started.html) set up. ## Customizing App Display Name and Icon You can edit `app.json` to include [configuration keys](https://docs.expo.io/versions/latest/guides/configuration.html) under the `expo` key. To change your app's display name, set the `expo.name` key in `app.json` to an appropriate string. To set an app icon, set the `expo.icon` key in `app.json` to be either a local path or a URL. It's recommended that you use a 512x512 png file with transparency. ## Writing and Running Tests This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` or with the `.test` extension to have the files loaded by jest. See the [the template project](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/App.test.js) for an example test. The [jest documentation](https://facebook.github.io/jest/docs/en/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/en/tutorial-react-native.html). ## Environment Variables You can configure some of Create React Native App's behavior using environment variables. ### Configuring Packager IP Address When starting your project, you'll see something like this for your project URL: ``` exp:// ``` The "manifest" at that URL tells the Expo app how to retrieve and load your app's JavaScript bundle, so even if you load it in the app via a URL like `exp://localhost:19000`, the Expo client app will still try to retrieve your app at the IP address that the start script provides. In some cases, this is less than ideal. This might be the case if you need to run your project inside of a virtual machine and you have to access the packager via a different IP address than the one which prints by default. In order to override the IP address or hostname that is detected by Create React Native App, you can specify your own hostname via the `REACT_NATIVE_PACKAGER_HOSTNAME` environment variable: Mac and Linux: ``` REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start ``` Windows: ``` set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start ``` The above example would cause the development server to listen on `exp://my-custom-ip-address-or-hostname:19000`. ## Sharing and Deployment Create React Native App does a lot of work to make app setup and development simple and straightforward, but it's very difficult to do the same for deploying to Apple's App Store or Google's Play Store without relying on a hosted service. ### Publishing to Expo's React Native Community Expo provides free hosting for the JS-only apps created by CRNA, allowing you to share your app through the Expo client app. This requires registration for an Expo account. Install the `exp` command-line tool, and run the publish command: ``` $ npm i -g exp $ exp publish ``` ### Building