In this post I would like to note down the command line commands I usually use when developing my app and what exactly each command does and how! Or at least I will try to do so! You know the feeling when you do not know something so well although you are using it and it works! But… when you try to explain it in plain words, you suck! Yep… I am there! However, I promise to give my best!
I am using the command line tool react-native-cli, NOT the create-react-native-app tool! The latter was quite recently released and they even changed the Getting started page: it now has two tabs, but we are sticking with the second. The react-native-cli package! The tab you are looking for is this:
Building Projects with Native Code
at the top of the page! One of the main reasons is that you cannot use the full power of Android with the create-react-native-app tool. It has in general a lot of specific things and procedures you have to follow like the Expo app etc. A lot of dependencies for me! Maybe they changed it but when I used it, after a while did not have fun anymore!
Back on track, react-native-cli has two main commands I am using regularly, one to install the app on your phone (ohh, I forgot that I like using my phone as the dev station!) and the other to start the dev server at http://localhost:8081
This command installs your app in your phone! Either Android phone or iOS phone! Guess the command for iOS. We presume that you have already started your project with the command
react-native init YourProjectName
To be honest I do not how to explain this any further but I think this command builds the Anroid app and tranfers it to your phone. That’s it! You run it whenever you want to pass the changes you make to your app so you can update the app in your phone: imagine like updating through Play Store!
I do not know why again but this fails in my case! I have to use the flag and flush the caches every time like this:
react-native start --reset-cache
I do not remember where I found this (really it was after a lot of googling around), but the I think the reason is that the packager has caching turned on by default to speed up things, but as with browser caching sometimes you cannot see the changes even after clearing the cache twice! So, although it is kinda slower to build every time etc. it is more safe for use!
So these two are the commands I use regularly when I work on my app!
That’s it for now!
In the next post I will gather all the interesting modules I have used so far and write a couple of stuff about each one of them! Thanks!
I forgot to mention about the debugging command I frequently use, which is this one:
This logs in the terminal any console.log you write inside your code! Truly useful!