ReactJS and React Native similarities and differences
ReactJS is a JavaScript library created by Facebook to tackle the User Interface needs for high performance and dynamic. The JavaScript library was released in 2011 bringing a fresh outlook on rendering pages, which resulted in dynamic and responsive user input.
React Native, a mobile-app development framework hybrid available for iOS and Android, was released 4 years later after the popularity of ReactJS increased due to the Facebook’s team open sourcing it. ReactJS and React Native are similar in one way, but in others, they are completely different.
To be an experienced and credible React Native developer, one should understand that some amount of knowledge of JavaScript ES6 — the most recent version of the language. Because ReactJS is the core of React Native, understanding of the former is key. It wouldn’t also hurt to know your way around Node.js and then you can finally start your adventure with React Native.
Start-up
Contrary to ReactJS, where the developer has to choose a bundler while trying to pick which of the bundling modules will be best for the project, React Native delivers everything needed. Coding of the first native app can start shortly after you type one command line, making RN easy and fast to set up.
All the HTML
React Native doesn’t use HTML for app rendering. Instead, delivers components working similarly and most of them can be translated into their equivalents in HTML, e.g. <View> to <div> and <Text> to something like a mixup of <span> and <p>. Due to this, the libraries used with ReactJS cannot be used in the React Native framework. React Native doesn’t use CSS tags or rather uses them in a different way, similarly to Flexbox.
Gestures and animations
React Native provides a library similar to Velocity.js called Animated. React-Native also provides LayoutAnimation, which unfortunately is only well supported by iOS.
For interaction with the user’s gestures, React Native provides PanResponder. By applying it to a View you enable the touch handler on it.
What remained
Although there are more differences than similarities between ReactJS and React Native, some characteristics are relevant to both. People tend to say that the main similarity of the two is the lack of documentation on both. On the contrary, since the release of React 16, the documentation is great and is available on the official website.
React-Native uses ReactJS as its JavaScript library, so building a cross-platform app only calls for proficiency in JavaScript and knowledge of the React syntax.
You can use most developer tools dedicated for ReactJS in the RN framework, e.g. Chrome Dev Tools for displaying the console logs and inspecting the network requests or Redux DevTools for inspecting the state of the Redux store.
Summary
Both ReactJS and React Native are great for fast complex UI building and transitioning from the former to the latter isn’t hard for those who enjoy learning new JavaScript frameworks. What should be remembered is:
- React Native is a framework while ReactJS is a JavaScript library
- React Native doesn’t use HTML
- ReactJS gives all the advantages of React Native
- ReactJS and React Native both follow component-based architecture
- You can write native mobile components in React Native to give off the feeling of a mobile app