In this homework assignment, we are going to be making a rudimentary app and loading it onto an iOS or Android device with Expo Go. If you've followed homework assignments 1 - 9, you already have your computer set up to do this and have learned all the skills you need to do it. We are going to be using a framework called React Native to do this. React Native, as well as its predecessor React, has been developed by the company behind Facebook. A number of apps you use every day were created using React Native - Microsoft Teams and Outlook, Discord, as well as the Facebook app itself.
If you are coming to this homework assignment straight from the end of homework 9, you currently have an image downloaded called "expo_test", you have it running as an container and you have that container loaded in a dedicated VS Code window. If not, go back to the end of homework assignment 9 and get back to this point.
Now we are going to generate a simple app. With the terminal open, enter the following command and press enter:
npx create-react-native-app my-app
Lets break this down - we are running software called npx, we are using the command create-react-native-app and we are creating an app called my-app. By the way, we can change my-app to anything else we want, but you'll need to change it in all subsequent commands too.
Upon entering the command we discussed above, we are presented with some options:
![image](https://private-user-images.githubusercontent.com/43721202/243205707-a4ee366e-fa0b-4185-af6a-7878070c6be5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzNDk4OTcsIm5iZiI6MTcyMjM0OTU5NywicGF0aCI6Ii80MzcyMTIwMi8yNDMyMDU3MDctYTRlZTM2NmUtZmEwYi00MTg1LWFmNmEtNzg3ODA3MGM2YmU1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDE0MjYzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNhYjc4MTUwZmRkMDY4ODA3MzQ2OGRjNWE1NThiN2JjNjIzOTFjNWUyZGMzOTc1ZjcyM2FmOGM2NjU1MzBkZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MzUQGJSFzNcGZcsRdC1Jdx8gzjDxPITJOo9wehK_uA8)
Let's go with "Template from expo/examples". We are then given a list of example apps that we can chose from. You are free to chose any of the templates that you want and I recommend trying out a few different ones after you finish this tutorial. However, for now I recommend navigation as it is nice and simple. When you press enter, the system will start installing all the required packages you need for this app to work which might take about 5 minutes. Eventually you should see a message saying that it was successfully installed.
A folder has now been created in this directory that contains all the files for this app. Do you know how to move the terminal into this folder? As a little test, I want you to figure it out. It's very simple: either search online how to change directory in a Linux terminal or ask someone you know. The command might be right there on the terminal already. If you get stuck, message me or write a reply in the comments below.
Once you you're in the directory for the app, you are going to run the app and load it onto a device. Type and enter the following command:
yarn start --tunnel
You might be asked to install some extra packages associated with Expo. This is fine and you should press the Y key to accept. Once all that is done, we now have a server running which allows you to access the app via our devices. You should be presented with something similar to the below which includes a QR code.
![image](https://private-user-images.githubusercontent.com/43721202/243206701-0b06901b-451e-49a1-af50-8c36e1913450.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzNDk4OTcsIm5iZiI6MTcyMjM0OTU5NywicGF0aCI6Ii80MzcyMTIwMi8yNDMyMDY3MDEtMGIwNjkwMWItNDUxZS00OWExLWFmNTAtOGMzNmUxOTEzNDUwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDE0MjYzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxZmMyMzBmMmMyYTMwMzI3MzlhNjdiOGZjNTI4ZGVjMDdkZTMyNWIxZTdlNzk0NjhkNzQ3ZjIzODM2ZDdlYmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RDVVFfvKyt8ba9knDyQEJHM8RYaC-nJ9G3TFjLgRLYk)
Don't worry about the warning regarding the version of React Native being slightly out of date. You can either safely ignore it or try to fix it using the commands it offers.
Now, pick up your Android or iOS device - it needs to be connected to the same network as your computer that VS Code is running on. Also, if you are using a VPN, now might be a good time to temporarily disable it. f you are using Android you should load up the Expo Go app and use the QR scanner option. If you are using iOS, simply scan the QR code with your camera and follow the link. Either way, a loading screen should appear on your device followed by the app being loaded up. If you went with the navigation example, you should see something like this:
![image](https://private-user-images.githubusercontent.com/43721202/243207056-f7107eec-3c99-4e20-80fe-06d016a91ea1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzNDk4OTcsIm5iZiI6MTcyMjM0OTU5NywicGF0aCI6Ii80MzcyMTIwMi8yNDMyMDcwNTYtZjcxMDdlZWMtM2M5OS00ZTIwLTgwZmUtMDZkMDE2YTkxZWExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDE0MjYzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQyMTM2N2ExYzQyN2FjYzc5NTI4MjE3YmE3OGQ5MmM4NzE2YjQ5ZTk2NDViOWNiNDc0Mjk0NWIzZjAzYzBjY2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iYWyfeAE_4CqaQ1u35VjQtIpboWNADJNqBQP0mbZ8XA)
You now have your very own very simple app! Congratulations, you've just taken a huge leap towards becoming an app developer. To close it down, click on the terminal and press Ctrl+c. To make another app, perhaps using one of the other examples, navigate to the parent directory of the current one and repeat the above process again.
In the next homework assignment, we will be editing parts of the code in order to customise our app.