Active smartphone users might have noticed that the number of mobile applications in the AppStore and Google Play is growing daily. This report serves as evidence to this, and, despite the apparent colossal difference between the user numbers on the most popular platforms - Android and iOS - both have rather large audiences, making their developers successful. The easiest and least expensive way to create applications for two platforms at once is cross-platform development frameworks instead of a framework for building native apps.
In this article, we will discuss React Native. This is one of the most popular environments for the development of cross-platform mobile apps, to which many progressive IT companies are switching. In addition, we provided a brief manual on how to build a mobile app with React Native components.
Why React Native?
For example, if you decided to make your application cross-platform, you probably already reviewed your share of opinions that might potentially help you overcome the difficulties of making a choice in favor of a particular solution among a large number of suitable frameworks for these purposes.
Here is a list, though not entirely complete:
- Appcelerator Titanium;
- Phone Gap browser wrapper;
- Ionic (focuses exclusively on creating layouts and UIs);
- Ext JS;
- JQuery Mobile (obsolete), etc.
React Native was not included in this list because it is far ahead of all the mentioned development environments. Now we will explain why. The cross-platform application’s principle of operation lays in the following. The code is launched in the browser window or wrapper on the mobile device. Browser modules allow access to APIs, hardware and software capabilities of the device. Since layout drawings and page renderings (JS, HTML, CSS) is performed on the client side, it may take some time. From the user’s point of view, this results in low responsiveness (which, in turn, can be a complete fail for your application if it actively uses a touchpad or an accelerometer). This situation is further aggravated by the slow DOM rendering. React Native employs virtual DOM, a lightweight copy of it, which makes the mobile application much faster than the usual HTML5/JS application. In addition, RN uses a separate thread to start the application execution (that is, it does not block the main thread that is intended for the user interface). Sound impressive? React Native’s advantages were the major reason it was chosen for the development of such popular applications as Facebook, Instagram, 2gis, and Meduza.io.
More About React Native: Where its Uniqueness Lies?
Moreover, due to the constant improvement of the old operation mechanisms and the appearance of new ones (for example, React Fiber), the level of efficiency of these applications is almost identical to their native alternatives. This is the main advantage of this framework - get a high-quality and smoothly running mobile software using web technologies.
But this is not the only one of React Native’s advantages. They also include the abundance of technologies that can be used in the process of working on the project (such as Redux, Reflux, MobX, and many others). RN is also not limited in its ability to integrate pieces of code in less traditional languages - TypeScript, ClojureScript, and CoffeeScript.
What Are the Less Significant Practical Advantages of the React Native App Development?
Above, we got acquainted with the features of RN, which distinguish it from other well-known frameworks for cross-platform development. Now, let us consider the less significant benefits that are nevertheless important for developers.
Bypassing AppStore policies when pushing updates. Not quite significant, however, still annoying: in order to be published through the AppStore, an update must pass a two-day test review. With RN, you do not have to wait. You can create "live" updates that will instantly be uploaded to the AppStore.
Simpler UI development. If you have not had the experience of native development yet, then we’ll warn you about the possible difficulties associated with the imperative writing style inherent to Java, Objective-C or Swift. Replace the single row and the application will suddenly work incorrectly. With React Native and JS, everything is much simpler. Adhering to the declarative style of code creation (intrinsic to good old HTML), you can concentrate more on the development of the functionality itself, rather than on methods and principles of its correct implementation.
Accelerated debugging. RN uses the specific function of Hot Reload during debugging. The idea is to maintain the current state of the application while adding new versions of files that have been edited during the execution of the code. In order for these new files to go through the debugging process, no more than one second is needed, in most cases.
Reduction in required labor resources. The huge advantage of React Native is that, unlike native development, there is no need to involve two separate teams for iOS and Android (and perhaps more, if you plan to support more than two mobile platforms).
Creating a Simple Application with React Native
In order to see how to use ReactJS in the native mobile app development, we will try to create a mobile app with ReactJS, with which the user can operate the list of employees of an organization, as well as their personal data. Let us start looking at this brief tutorial.
1. Install Node.js. If you already have React Native installed, you can safely skip this step. Note that these recommendations are similar to both Windows and MacOS. First, you need to install Node.js. This is done with the help of Homebrew. Node.js is downloaded and installed using the following terminal command:
brew install node
2. Install Watchman. Now, install the module for reading files: Watchman. Enter the following command into the terminal:
brew install watchman
3. Install CLI. Use the NPM package manager to install CLI with the following command:
npm install react-native-cli -g
4. Create the project structure. Move from the terminal to the project folder and enter the following:
react-native init Employee
In this way, we will create all the files needed to run the application on both platforms. Now start the file Employee.xcodeproj, which can be found in the folders XCode/iOS or XCode/Android (for simplicity, we will continue to consider building an iOS app with React Native, building the application with React Native for Android will look absolutely similar). As a result, the simulator displays the following:
When you assemble the project, you will receive a window with recommendations for further action. In particular, it will say that, to use the SDK, one must press ‘Command+Control+Z’ and reload the application with ‘Command+R’.
5. Start the development. Open the file ‘index.ios.js’ and input the following lines into it:
Here, the ‘AppRegistry’ command indicates the entry point to the application and defines the root component.
Note that the structure of any application on React Native is as follows:
Now we need to change ‘App.js’. The application we create will use two elements: a search function and a panel with the employee list. They are within the application - tabs that are created using the ‘TabBarIOS’ component. Thus, each of the tabs will require the creation of its own ‘TabBarIOS.Item’. In addition, we will need to describe the methods ‘_employeesOnPress’ and ‘_searchOnPress’, which will handle the relevant components and be responsible for the state of the user selected tab.
Next, we need to describe ‘EmployeesTab’ and ‘SearchTab’ components, which act as wrappers for the ‘NavigatorIOS’ component that generates routes for tabs. To do this, enter the following lines:
The next step is to add the option to scroll the list of employees to the ‘Employees’ component. To do this, we will create a ‘ListView’ component, to which all our employees will be "tied." Let us see how the process of binding and transferring data about employees to the ‘EmployeesList’ presentation component is performed:
This module will render the current state of the application when the user clicks on the screen. In particular, for these purposes, we will need the ‘TouchableHighlight’ method, which ensures the responsiveness of the application to user taps. Let us introduce the following code into the project:
Next, we will add the search function. Thanks to this, any user will be able to find an employee by their name. In order to implement this feature, you will need to create the ‘Search.js’ component in the ‘containers’ sub-folder and put the following code into it:
Thus, with each user request, the connection to the API will be established, which will display the requested information (in this case - a particular employee’s personal card).
And, we are done! Now let us review the screenshots that show what a ready application might look like:
Cost to Develop a Mobile App with React Native Components: How Much Man-hours Will Each Stage of Development Require?
The overwhelming majority of investors believe that, if the cost of developing a native application is a certain amount (let us denominate it N), then the cross-platform cost will be at least twice as cheap. Our experience in developing mobile software with cross-platform frameworks evidence that this statement can be wrong for applications with complex business logic, as well as for those that actively use mobile device capabilities (camera, contact book, GPS, image editors, etc.). In this case, the cost of cross-platform development will be about 0.9*N. The reason for this rather high coefficient is the specificity of the development for the Android platform: many Android smartphone manufacturers create their own versions of this platform, the nuances of which may not be taken into account in cross-platform frameworks. With React Native, the situation is radically different. As already noted above, the interface of software created with the help of RN is completely native for each of the platforms, so developers will not need to spend their time checking it across different OEM variants. Nevertheless, regardless of the chosen framework, when the budget allocated for software development is estimated in tens of thousands of dollars, even such a seemingly insignificant difference can become a decisive argument for investors in favor of cross-platform. What is the approximate price of the project? Let us find out how high a price it can fetch, in man-hours. React Native app development stages of the cross-platform mobile application can include:
- Engineering. Planning is an integral part of the software creation process. It involves choosing the appropriate tools and methods for implementation of the intended functionality, as well as the distribution of responsibilities and tasks. Typically, this phase takes at least 80 man-hours.
- Coding. Attention must be paid not only to the application’s logic but also to the design of its user interface. To make a mobile app with ReactJS, developers need at least 1,000 man-hours.
- Testing. No successful software can do without alpha and beta testing. Depending on specifics, testers will need at least 80 man-hours.
Technical support. To ensure that the application does not lose its relevance over time, you will need to regularly supply updates (or, at the very least, solve the problems and eliminate defects found after its release). For these purposes, a remote team would be enough. On average, a separate update would take anywhere from 60 to 120 man-hours.
Depending on app complexity and taking into account hourly rates of developers from ex-USSR countries, the typical React Native app development can cost anywhere between $38,000 and $100,000.
If building a mobile app with React Native is a complex task for you, contact us today!
Applikey Solutions is a development team that, for years, has been working on various software solutions for mobile platforms and web. Among our achievements are already more than 100 successfully implemented projects. Therefore, if you have an idea for a startup, but you do not know how to embody it into the mobile software format - hire our company for our development services! Contact our experts today to discuss the details of cooperation (we also have experience in remote collaboration).