React Navigation for V5 Demo Application Docker + Expo The procedure for running on a mobile device (iOS or Android) using is posted.
If you are studying about React Navigation, please give it a try.
We are currently procuring an Android device and will verify it at a later date, but in theory, the Android device should work with the same procedure.
PC
iPhone
--Expo account registered
The procedure for registering an account is described in the separate article "How to create an Expo account".
--docker, docker-compose installed --git installed
--Expo Client installed
The installation procedure is described in another article "How to install and set up the Expo client app on iPhone".
Use the terminal to create and move the project folder.
mkdir react_navigation_demo
cd react_navigation_demo
Download the react-navigation repository on github with the clone command.
git clone https://github.com/react-navigation/react-navigation.git
Create each configuration file for Docker and EXPO.
touch dockerfile
touch docker-compose.yml
touch .env
Describe the settings in the docker file
```
FROM node:14-alpine
WORKDIR /usr/src/app/
RUN apk update && apk add bash
```
Describe the settings in docker-compose.yml
```
version: "3"
services:
react-navigation:
build: ./
volumes:
- ./react-navigation/:/usr/src/app
env_file: .env
command: bash -c "cd example && yarn start"
ports:
- "19000:19000"
- "19001:19001"
- "19002:19002"
```
Describe the settings in .env
It is necessary to set the IP address of each terminal that uses Expo. - ADB_IP: Please specify the IP address of the mobile device. It seems that you can specify multiple items separated by commas. - REACT_NATIVE_PACKAGER_HOSTNAME:
Please specify the IP address of the PC terminal that starts Docker.
```
ADB_IP=192.168.1.106, 192.168.1.107
REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.204
```
Build the Docker environment
docker-compose build
Setup on Docker container
Connect to the Docker container
```
docker-compose run --rm react-navigation bash --login
```
Navigate to the example folder
```
cd example
```
Set up with yarn
```
yarn
```
Close the connection with the container
```
exit
```
Start Docker
docker-compose up
Read the QR code displayed on the terminal with your mobile device
![Screenshot 2020-09-30 13.25.54.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/249974/0ec28cc2-126b-94f5-5b09- ad648541e37a.png)
The demo app will launch on your mobile device
Recommended Posts