React Native
React
JavaScript
Web Development
Mobile App Development

What is the difference between React Native and React?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

React and React Native are both open-source libraries developed by Facebook that are widely used for building user interfaces. While they share a common architectural foundation and philosophy, they cater to different platforms and have distinct purposes and functionalities. Understanding their differences is key for developers choosing the right technology for their project.

Core Philosophy and Common Ground

React, also known as React.js, was introduced in 2013 and is a JavaScript library for building dynamic user interfaces for web applications. React Native, launched in 2015, extends React's architecture to build native mobile applications for iOS and Android.

Both use JSX (JavaScript XML), which allows developers to write HTML in React within JavaScript code. They share the same design principles, such as the virtual DOM (Document Object Model) for efficient re-rendering of the UI, and a component-based structure where each component maintains its own state and logic.

Platforms Targeted

The key difference between React and React Native lies in their target platforms:

  • React is used for web development.
  • React Native is used for mobile app development on platforms like iOS and Android.

Technical Interventions

Rendering Components

In React, components render to a web browser's DOM. Developers typically use additional libraries like ReactDOM for rendering workflows specific to web browsers.

React Native, however, does not use HTML to render components. Instead, it uses native components that map to real, native iOS or Android UI components that render directly to the mobile device’s screen.

Styling

React uses CSS for styling. This can be done using external style sheets or inline styling.

React Native has a different approach, using a JavaScript object to style components. The styling properties closely resemble CSS but use camelCase syntax like backgroundColor instead of background-color.

In web applications built with React, browser-based routing is used. React Router is a popular library that helps manage transitions between different views in the application.

React Native uses libraries like React Navigation or react-native-router-flux, which provide a more mobile-centric method of navigation, such as tab navigation, stack navigation, or drawer navigation.

Development Environment and Setup

  • React development typically involves setting up a code bundler like Webpack and a development server.
  • React Native comes with its own CLI tool called create-react-native-app which simplifies the process of setting up a new mobile app project.

React Native additionally requires developers to have either Xcode or Android Studio to run the iOS or Android simulations, respectively.

Performance

React applications run on the web, so their performance often depends on the browser's capability to render JavaScript quickly.

React Native applications, by comparison, have the advantage of leveraging the device's native performance capabilities which can be considerably faster, as it converts the JavaScript components into native platform-specific ones.

Use Cases

Choose React for:

  • Rich interactive web applications.
  • Projects where SEO might be a concern as server-side rendering is more SEO-friendly.
  • Applications where progressive web app (PWA) features are needed.

Choose React Native for:

  • Projects aimed at a native mobile experience without the complexity of learning Swift/Objective-C or Java/Kotlin.
  • Applications that need to access mobile-specific functionalities like the camera, accelerometer, etc.

Summary Table

FeatureReactReact Native
PlatformWebiOS and Android Mobile Apps
Component RenderingRenders to DOMRenders to Native Components
StylingCSSJavaScript Objects
NavigationReact RouterReact Navigation, Native Navigation
Development ToolsWebpack, BabelReact Native CLI, Xcode, Android Studio
PerformanceDepends on browserClose to native performance
Typical Use CaseWeb apps (SPA, MPA)Native mobile apps

By understanding these differences, developers can better decide which platform suits their needs for specific applications. As both are JavaScript-based and share similar design philosophies, transitioning between them or integrating them into a single project can be more straightforward than working with entirely different frameworks.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.