Understanding Reactive Native
Simply put, React Native is a framework for building apps in Android and iOS using JavaScript. It was created by FaceBook in 2015 and has gained much popularity around the world in the last few years. Knowing JavaScript will allow you to build actual native apps for Android and iOS, not just a website that looks like a mobile app.
React Native does not require you to learn Android or iOS programming unless you are building a very complex app that involves reaching native APIs of those platforms, which is rarely the case. Here you can just write all your code in JavaScript and share it across both platforms.
For this reason, most companies these days prefer to build their apps using React Native. They don’t need to hire two separate teams of developers to maintain two different codebases. One for Android using Java or Kotlin, and one for iOS using Swift or Objective-C.
Another reason many companies love React Native is faster time-to-market and increased developer productivity. It has an amazing feature called “hot reload” where any changes are instantly rendered on your phone or simulator. In typical native development, every time you make a change, you have to compile your code before seeing any changes. This can take over a minute depending on the size of your app.
A common misconception is that React Native is not useful for building serious apps. This can not be any further from the truth. Some examples of apps that are built in React Native include FaceBook, Instagram, Skype, UberEats, Pinterest and many more.
ReactJs vs React Native
ReactJs developers transitioning to React Native should be aware of the key differences. The most obvious being ReactJs is used for web development while React Native for creating mobile applications.
It is important to note the differences in stability between the two. ReactJs is up to version 17.0.1 while React Native is only at version 0.63 at the time this piece was published. This might restrict mobile developers from including certain platform specific functionality in their app.
The promise of ‘learn once write everywhere’ is not exactly true for these frameworks. Structurally speaking, components can be connected in a similar way. But the actual code will look a little different. A big adjustment being that certain tags such as <div> or <p> are not a recognized in React Native. Instead, tags such as <view> and <Text> are used instead. The reason being that these map one-to-one with real components within native development, whether that is Java/Kotlin or Swift/C. Therefore you can not simply take ReactJs code and just run it on mobile.
Starting a new React Native project also has its own methodology. Running create-react-native-app builds your project in a folder called .expo.
Another key difference is the styling of each framework. They both use JSX for the development of view templates. ReactJs allows you to style the application much more easily using CSS. React Native on the other hand makes use of native platform APIs for styling.
Live Reload is another area where the two sides differ. Live Reload (or Hot Reload) is a feature that allows you to modify code and see changes in your app simultaneously. ReactJs does not support this feature while React Native does.
Advantages of using React Native
As one of the largest mobile development platforms, there are plenty of online resources available to learn from. React Native is a great fit when it comes to creating crud apps. These apps simply involve interaction with a server where you are reading and writing information. But if you are creating something highly performing that may involve animation, other frameworks such as Flutter might be necessary.
Should I use Expo?
A common decision React Native developers need to make is whether or not to use Expo on their project. One benefit of Expo is that it allows you to build React Native apps very fast as it does not require any build configuration. Expo also allows you to code in only JavaScript, making it a better option for devs who do not wan’t to touch native code, Xcode, or Android Studio. And lastly, with Expo you can publish Over The Air (OTA) updates at anytime.
Expo does have some restrictions. For example, not all Android and iOS APIs are available in Expo. And aside from the inability to change native code, detaching your app will come at a cost. You may need additional coding for features like navigation changes or push notifications. Also, Expo is loaded with APIs that you may not use. This may prevent you from keeping your app lean. It is important to consider all requirements and native features in your app before deciding whether or not to use Expo.
Remember to test in both iOS and Android
It is common for many React Native developers to only test their app in iOS as they are iOS users themselves, making it more convenient. Running multiple simulators at a time can also slow down your system. But it is important to test in both Android and iOS in cross-platform projects as there may be some differences in component rendering. The ability to deploy to both platforms is what makes React Native so powerful in the first place.
There is a tremendous demand for React Native developers and hopefully this has helped you consider React Native in your next project.