• Stars
    star
    124
  • Rank 286,534 (Top 6 %)
  • Language
    JavaScript
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Demonstrating the react-navigation drawer for my blog post on medium

React Navigation Drawer Example

Review from the blog, or see it being built in 4 parts:

  • Step 0 - brand new app
  • Step 1 - react-navigation in place
  • Step 2 - react-navigation drawer in place
  • Step 3 - fix workflow breaks
  • Step 4 - custom drawer with logout

Review blog post for full analysis of steps. drawer example gif

Above steps do not have the same styles as the blog post


Generic App Readme:

This project was bootstrapped with Create React Native App.

Below you'll find information about performing common tasks. The most recent version of this guide is available here.

Table of Contents

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 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 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 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 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.
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, Linux, and Windows).
  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 set up.

Customizing App Display Name and Icon

You can edit app.json to include configuration keys 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 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 for an example test. The jest documentation is also a wonderful resource, as is the React Native testing tutorial.

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://192.168.0.2:19000

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.

Adding Flow

Flow is a static type checker that helps you write code with fewer bugs. Check out this introduction to using static types in JavaScript if you are new to this concept.

React Native works with Flow out of the box, as long as your Flow version matches the one used in the version of React Native.

To add a local dependency to the correct Flow version to a Create React Native App project, follow these steps:

  1. Find the Flow [version] at the bottom of the included .flowconfig
  2. Run npm install --save-dev [email protected] (or yarn add --dev [email protected]), where x.y.z is the .flowconfig version number.
  3. Add "flow": "flow" to the scripts section of your package.json.
  4. Add // @flow to any files you want to type check (for example, to App.js).

Now you can run npm run flow (or yarn flow) to check the files for type errors. You can optionally use a plugin for your IDE or editor for a better integrated experience.

To learn more about Flow, check out its documentation.

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 an Expo "standalone" app

You can also use a service like Expo's standalone builds if you want to get an IPA/APK for distribution without having to build the native code yourself.

Ejecting from Create React Native App

If you want to build and deploy your app yourself, you'll need to eject from CRNA and use Xcode and Android Studio.

This is usually as simple as running npm run eject in your project, which will walk you through the process. Make sure to install react-native-cli and follow the native code getting started guide for React Native.

Should I Use ExpoKit?

If you have made use of Expo APIs while working on your project, then those API calls will stop working if you eject to a regular React Native project. If you want to continue using those APIs, you can eject to "React Native + ExpoKit" which will still allow you to build your own native code and continue using the Expo APIs. See the ejecting guide for more details about this option.

Troubleshooting

Networking

If you're unable to load your app on your phone due to a network timeout or a refused connection, a good first step is to verify that your phone and computer are on the same network and that they can reach each other. Create React Native App needs access to ports 19000 and 19001 so ensure that your network and firewall settings allow access from your device to your computer on both of these ports.

Try opening a web browser on your phone and opening the URL that the packager script prints, replacing exp:// with http://. So, for example, if underneath the QR code in your terminal you see:

exp://192.168.0.1:19000

Try opening Safari or Chrome on your phone and loading

http://192.168.0.1:19000

and

http://192.168.0.1:19001

If this works, but you're still unable to load your app by scanning the QR code, please open an issue on the Create React Native App repository with details about these steps and any other error messages you may have received.

If you're not able to load the http URL in your phone's web browser, try using the tethering/mobile hotspot feature on your phone (beware of data usage, though), connecting your computer to that WiFi network, and restarting the packager.

iOS Simulator won't open

If you're on a Mac, there are a few errors that users sometimes see when attempting to npm run ios:

  • "non-zero exit code: 107"
  • "You may need to install Xcode" but it is already installed
  • and others

There are a few steps you may want to take to troubleshoot these kinds of errors:

  1. Make sure Xcode is installed and open it to accept the license agreement if it prompts you. You can install it from the Mac App Store.
  2. Open Xcode's Preferences, the Locations tab, and make sure that the Command Line Tools menu option is set to something. Sometimes when the CLI tools are first installed by Homebrew this option is left blank, which can prevent Apple utilities from finding the simulator. Make sure to re-run npm/yarn run ios after doing so.
  3. If that doesn't work, open the Simulator, and under the app menu select Reset Contents and Settings.... After that has finished, quit the Simulator, and re-run npm/yarn run ios.

QR Code does not scan

If you're not able to scan the QR code, make sure your phone's camera is focusing correctly, and also make sure that the contrast on the two colors in your terminal is high enough. For example, WebStorm's default themes may not have enough contrast for terminal QR codes to be scannable with the system barcode scanners that the Expo app uses.

If this causes problems for you, you may want to try changing your terminal's color theme to have more contrast, or running Create React Native App from a different terminal. You can also manually enter the URL printed by the packager script in the Expo app's search bar to load it manually.

More Repositories

1

ReactStateMuseum

A whirlwind tour of React state management systems by example
JavaScript
1,522
star
2

nsfw_model

Keras model of NSFW detector
Python
1,297
star
3

jail-monkey

A React Native library for identifying if a phone is rooted or mocking locations
Java
567
star
4

react-native-siren

The React Native port of the popular Siren / Harpy Pod and hopefully Gradle
JavaScript
153
star
5

learn-tfjs

The code for the book Learning TensorFlow.js by Gant Laborde - Published by O'Reilly Media
HTML
139
star
6

rps_tfjs_demo

Training a Rock Paper Scissors model in the browser via TFJS - Learn along style
JavaScript
86
star
7

fun-machine-learing

The most interesting and fun machine learning links!
71
star
8

nicornot

Using machine learning to identify if someone is Nic Cage or not
JavaScript
62
star
9

tictactoe-ai-tfjs

Train your own TensorFlow.js Tic Tac Toe
JavaScript
50
star
10

enjoytheshow

Real-time facial expression gathering
JavaScript
35
star
11

mobile-commander

A collection of useful React Native commands
Shell
33
star
12

Public_Speaking_Hits

A Helpful list of quick and useful public speaking lines
31
star
13

RedAlert

iOS Alerts and ActionSheets with ease
Ruby
24
star
14

motion-egg

Awesome little gem to add an easter egg to your RubyMotion app
Ruby
23
star
15

PackingPeanut

App persistent data for RubyMotion Android
Ruby
21
star
16

RNImagePreview

Using a simple cocoapod for image previews in React Native
Objective-C
15
star
17

WaveFun

Just messing around with React Native animation
JavaScript
15
star
18

tfjs-runway

Packages tfjs models for shipping with websites
TypeScript
14
star
19

yesyoucam

BluePotion Camera Library
Ruby
11
star
20

useless-things

The abandoned storage space of things that should have never been
JavaScript
9
star
21

ReactNative_MNIST

React Native implementation of the MNIST model in BrainJS
Objective-C
9
star
22

Food101

Machine Learning with React Native to identify food
Objective-C
8
star
23

ReactNativeGraphQLExample

I said I'd make it. Here's my GraphQL React Native Example
8
star
24

GantMan

My profile readme
7
star
25

home_splash

Simple beginner's Rails project to help illustrate some basics.
Ruby
6
star
26

TensorFlow-Data-and-Deployment-Specialization

Jupyter Notebook
6
star
27

rn-textables

A react native version of Textables
JavaScript
6
star
28

ignite-source-map

A CLI to parse source-map files and stack traces into usable output
JavaScript
5
star
29

timewarp

The timewarp filter with TensorFlow.js
HTML
5
star
30

RubyMotion-Intro

Presentation of Intro to RubyMotion
Ruby
5
star
31

RN_TF_Lite

React Native Tensorflow Lite - Code and example
Objective-C
4
star
32

over-armour

Rage Against the Crash
JavaScript
4
star
33

irrigate

Yeoman generator for Infinite Red app structure
JavaScript
4
star
34

ignite-redux-logger

Ignite plugin for redux-logger
JavaScript
4
star
35

WinGif

The delights of a gif on React Native Windows
C#
4
star
36

WackAMole

Basics for teaching components, flatlist, and animation
JavaScript
4
star
37

contact_solution

Contact Solution is your refreshing prescription for RubyMotion Android contacts data.
Ruby
3
star
38

packlist-components

Components for React Museum Apps - separated for clarity
JavaScript
3
star
39

workshop-app

Basic workshop app (agenda/conf)
JavaScript
3
star
40

solidarity-envinfo

Create and enforce envInfo results with Solidarity
JavaScript
3
star
41

wrong_way

Checking for people going the wrong way - uses AI-LAB and React
JavaScript
3
star
42

quickmirrorme

A simple website that is a webcam mirror
JavaScript
3
star
43

reform

Server for Proselyte model conversions
JavaScript
2
star
44

blightcam

Detect people or vehicles on blighted property - Demo
JavaScript
2
star
45

cryptex

Fun idea with blaze pose. Might finish it, might not.
HTML
2
star
46

ML_Octave

Octave/Matlab code for Machine Learning Exercises
MATLAB
2
star
47

CoffeeBoard

Sinatra project for my Raspberry Pi
Ruby
2
star
48

Pneumonia-classifier

99% accurate pneumonia classifier
Jupyter Notebook
2
star
49

multiverse

Snapshot builds of React apps and host them in folders
JavaScript
2
star
50

HuntClue

There are two errors in this React Native app that stop it from working
Java
1
star
51

RSM-Context

Created with CodeSandbox
JavaScript
1
star
52

ai_sort

Use AI to sort you into your house
HTML
1
star
53

rm-loop-speed

Testing loop speeds in RubyMotion
Ruby
1
star
54

simple-tfjs-transfer

Mobilenet with K-nearest-neighbors classifier transfer learning example
JavaScript
1
star
55

GreenRune

Website to Generate Greenrune Glyphs
JavaScript
1
star
56

adventure-bingo

Simple adventure-bingo game.
Ruby
1
star
57

BasicAppSyncExample

Using AWS AppSync
JavaScript
1
star
58

Siraj-week3-hw

Solution to week 3 homework
Jupyter Notebook
1
star
59

HelloWorld

The good old "Hello World" application for RubyMotion
Ruby
1
star
60

JQueryUI-Days-From-Now

Add number of days from now display with any jQuery UI datepicker.
1
star
61

crawfish

Simple RN app for finding crawfish prices near you.
JavaScript
1
star
62

model-convert

yup
JavaScript
1
star
63

transfer_trek

JavaScript
1
star
64

MachineLearningTraining

Notebooks for Fun ML by Gant
Jupyter Notebook
1
star
65

socialboard

The web app for the SocialBoard.io site
Ruby
1
star
66

tts_ruby

Ruby stuff from Tech Talent South Fulltime Class
Ruby
1
star
67

riddikulus

Sort drawings into their Hogwarts house
Jupyter Notebook
1
star
68

10-20-30-Running

RubyMotion source for 10-20-30 running app
Ruby
1
star
69

RSM-graphql-appsync

Created with CodeSandbox
JavaScript
1
star
70

furry_destroyer

A flash game I made 10+ years ago, still funny
ActionScript
1
star
71

greenrune_lab

Build your own Greenrune images in this WYSIWYG
CSS
1
star
72

basics

React Native Basics
JavaScript
1
star
73

Fashion-GAN

Create Fashion GAN from FASHION-MNIST
Jupyter Notebook
1
star