What is React Native? – Detailed Notes
Course: React Native Training
Topic: Introduction to React Native
Course Link: React Native Training Course
Demo Link: Register for a Free Course Demo
JustAcademy Website: Visit JustAcademy
1. Introduction to React Native
React Native is an open-source framework used to develop mobile applications for Android and iOS using JavaScript and React. It allows developers to build applications for multiple mobile platforms while sharing a significant portion of the codebase.
React Native was introduced by Facebook, now known as Meta. It grew from Facebook's efforts to apply React's component-based development approach to mobile application development.
Traditional native applications are commonly developed using platform-specific technologies, such as Kotlin or Java for Android and Swift or Objective-C for iOS. React Native offers an alternative by allowing developers to use React concepts and JavaScript or TypeScript to build interfaces using native platform components.
1.1 Definition of React Native
React Native is a cross-platform mobile application development framework that enables developers to build Android and iOS applications using React, JavaScript or TypeScript, and native user interface components.
1.2 Why Was React Native Developed?
- To simplify mobile application development across multiple platforms.
- To allow developers to reuse application logic and components.
- To reduce the need to maintain completely separate Android and iOS codebases.
- To use React's reusable component architecture for mobile interfaces.
- To help teams develop, test, and maintain mobile applications more efficiently.
1.3 Example of React Native Applications
React Native can be used to build applications such as shopping apps, food delivery apps, social networking applications, educational apps, business dashboards, booking platforms, and fitness applications.
2. Understanding the History of React Native
2.1 Background
Before React Native became available, many organizations maintained separate codebases for Android and iOS. Although this approach provides extensive platform-specific control, it can require additional development time and maintenance effort.
React Native emerged from the idea of using React's development model to create mobile interfaces with native components rather than building every screen as a traditional web page.
2.2 Development Timeline
| Period |
Development |
| 2013 |
React was introduced, establishing a component-based approach to building user interfaces. |
| 2015 |
React Native was publicly introduced by Facebook as a framework for mobile application development. |
| Following years |
The framework expanded its ecosystem, tooling, platform integrations, and community support. |
| Modern development |
React Native supports contemporary development workflows, TypeScript, improved native interoperability, and modern architecture features. |
2.3 React vs. React Native
React is a JavaScript library primarily used to build user interfaces, especially for web applications. React Native uses React concepts to build native mobile application interfaces.
- React: Commonly renders HTML elements in a browser.
- React Native: Renders native platform interface components such as View, Text, and TextInput.
- Shared concept: Both use components, props, state, and declarative UI development.
3. Key Features of React Native
3.1 Cross-Platform Development
React Native allows developers to target Android and iOS from a shared project. Common business logic and many interface components can be reused across platforms.
3.2 Component-Based Architecture
An application is divided into smaller reusable components. Each component can represent an individual part of the interface, such as a button, header, product card, or login form.
3.3 JavaScript and TypeScript Support
Developers can write React Native applications using JavaScript or TypeScript. TypeScript adds static type checking that can help identify certain errors during development.
3.4 Native User Interface Components
React Native provides components that map to native platform UI elements. This allows applications to deliver interfaces that behave more like mobile apps than ordinary websites.
3.5 Fast Refresh
Fast Refresh allows developers to see many code changes reflected quickly during development without restarting the entire application. Some changes may still require a reload.
3.6 Reusable Code
Developers can reuse components, validation rules, data models, API services, and business logic. Platform-specific code may still be required for certain features.
3.7 Access to Native Features
React Native applications can integrate with mobile capabilities such as the camera, location services, notifications, and device sensors through supported APIs and native libraries.
3.8 Large Ecosystem
The React Native ecosystem includes development tools, libraries, navigation solutions, testing frameworks, and community resources that support application development.
4. How React Native Works
React Native lets developers describe an interface using React components. The framework coordinates JavaScript application logic with native platform rendering and supported native APIs.
4.1 Basic Working Process
- The developer writes components using JavaScript or TypeScript.
- React processes the component tree and manages UI updates.
- React Native coordinates the required interface changes through its rendering and native integration systems.
- The Android or iOS platform displays the corresponding native UI components.
- User interactions trigger event handlers, state changes, and subsequent interface updates.
4.2 React Native Architecture Overview
Developer Code
|
v
React Components
|
v
React Rendering and Application Logic
|
v
React Native Runtime and Native Integration
|
v
Android / iOS Native UI and Platform APIs
This diagram is a simplified conceptual overview. Actual execution details depend on the React Native version, runtime, architecture, and libraries used by the application.
4.3 JavaScript Runtime
React Native executes application JavaScript in a supported JavaScript runtime. The application communicates with native platform functionality through React Native's integration mechanisms and any required native modules.
4.4 Native Rendering
Unlike a typical web application, React Native does not normally render its main interface using HTML elements and the browser DOM. It uses native UI components and platform capabilities.
5. React Native vs. Native App Development
| Feature |
React Native |
Native Development |
| Languages |
JavaScript or TypeScript, with native code when needed |
Commonly Kotlin or Java for Android and Swift or Objective-C for iOS |
| Platforms |
Shared development approach for Android and iOS |
Usually separate platform-specific implementations |
| Code Reuse |
Often high for shared logic and components |
Typically lower across Android and iOS implementations |
| User Interface |
Native UI components coordinated by React Native |
Platform-native UI APIs and frameworks |
| Performance |
Suitable for many application types; depends on implementation |
Direct platform control can be advantageous for specialized workloads |
| Native APIs |
Available through built-in APIs, libraries, or custom native modules |
Direct access through platform SDKs |
| Development Team |
Useful for teams familiar with React and JavaScript |
Requires platform-specific expertise for each target |
| Best Fit |
Cross-platform business and consumer mobile applications |
Applications requiring extensive platform-specific capabilities or specialized optimization |
6. React Native vs. React.js
| Basis |
React.js |
React Native |
| Primary Purpose |
Building web user interfaces |
Building mobile application interfaces |
| Rendering Target |
Web browser |
Native mobile UI |
| Common Elements |
div, p, button, input |
View, Text, Pressable, TextInput |
| Styling |
CSS and related web styling systems |
JavaScript style objects and React Native styling rules |
| Navigation |
Web routing libraries |
Mobile navigation libraries and platform navigation patterns |
| Deployment |
Web hosting and browser delivery |
Mobile app distribution or supported deployment approaches |
7. Advantages of React Native
- Code sharing: Many components and business rules can be shared across platforms.
- Development efficiency: Shared code can reduce duplicated implementation work.
- Familiar technology: React developers can transfer many existing skills to mobile development.
- Reusable components: Common interface elements can be developed and maintained independently.
- Rapid feedback: Fast Refresh can speed up iterative development.
- Native integration: Applications can use device features through suitable APIs and libraries.
- Community resources: Developers can access documentation, learning materials, and third-party packages.
- Maintainability: A well-structured shared codebase can simplify updates and bug fixes.
8. Limitations of React Native
- Platform differences: Android and iOS can require different interface adjustments or platform-specific code.
- Native dependencies: Some libraries require native configuration and platform development knowledge.
- Performance considerations: Complex animations, graphics, or computationally intensive tasks may require careful optimization or native implementations.
- Dependency maintenance: Third-party libraries may differ in compatibility, quality, and maintenance status.
- Build configuration: Native build tools and platform SDKs can introduce setup and troubleshooting challenges.
- Not identical to web development: HTML, browser DOM APIs, and ordinary CSS cannot be used as if the application were a standard web page.
9. Applications and Use Cases of React Native
9.1 E-Commerce Applications
React Native can power shopping applications with product listings, search, shopping carts, user accounts, and order tracking.
9.2 Social Networking Applications
Developers can create feeds, user profiles, messaging interfaces, notifications, and media-sharing experiences.
9.3 Education Applications
Educational apps can include recorded lessons, quizzes, course progress, learning resources, and student dashboards.
9.4 Food Delivery Applications
Food delivery applications may include restaurant listings, menus, order placement, location tracking, and payment integrations.
9.5 Business Applications
Organizations can build internal tools for inventory management, employee services, sales reporting, field operations, and customer relationship management.
9.6 Booking and Travel Applications
Booking platforms can use React Native to provide search, availability displays, booking workflows, itinerary details, and account management.
10. Important React Native Components
| Component |
Purpose |
Example Use |
| View |
Groups and lays out interface elements |
Screen containers and cards |
| Text |
Displays text |
Headings, labels, descriptions |
| Image |
Displays images |
Product photos and avatars |
| TextInput |
Accepts user text input |
Login forms and search fields |
| Pressable |
Responds to press interactions |
Custom buttons and clickable cards |
| ScrollView |
Provides scrolling for contained content |
Forms and shorter scrollable screens |
| FlatList |
Efficiently renders long lists of items |
Product lists and message histories |
| ActivityIndicator |
Displays a loading indicator |
Waiting for API responses |
| SafeAreaView |
Provides safe-area layout support where applicable |
Protecting content from certain screen insets |
11. Your First React Native Example
The following example demonstrates a simple screen with a heading, description, and interactive button. It can be used in a React Native project configured with the required dependencies.
import React from 'react';
import { View, Text, Pressable, StyleSheet } from 'react-native';
export default function App() {
const [message, setMessage] = React.useState('Welcome to React Native!');
return (
<View style={styles.container}>
<Text style={styles.title}>My First Mobile App</Text>
<Text style={styles.message}>{message}</Text>
<Pressable
style={styles.button}
onPress={() => setMessage('You clicked the button!')}
>
<Text style={styles.buttonText}>Click Me</Text>
</Pressable>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
backgroundColor: '#f5f5f5',
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 12,
},
message: {
fontSize: 16,
marginBottom: 20,
},
button: {
backgroundColor: '#2563eb',
paddingVertical: 12,
paddingHorizontal: 20,
borderRadius: 8,
},
buttonText: {
color: '#ffffff',
fontSize: 16,
fontWeight: 'bold',
},
});
11.1 Code Explanation
- Import React: Provides React functionality for building components and managing state.
- Import components: View, Text, Pressable, and StyleSheet are used to construct and style the screen.
- Create App: Defines the main functional component.
- Manage state: useState stores the message displayed on the screen.
- Build the interface: View groups the content, while Text displays information.
- Handle interaction: Pressable runs a callback when the user presses the button.
- Apply styles: StyleSheet organizes the component's layout and visual properties.
12. Styling in React Native
React Native uses JavaScript objects to define component styles. Although the styling approach resembles CSS, the available properties and value formats are not identical to web CSS.
12.1 Example of Styling
const styles = StyleSheet.create({
card: {
backgroundColor: '#ffffff',
padding: 16,
margin: 10,
borderRadius: 12,
elevation: 3,
},
title: {
fontSize: 20,
fontWeight: 'bold',
color: '#222222',
},
});
12.2 Important Styling Concepts
- Flexbox: Arranges elements using flexible rows and columns.
- Spacing: Padding and margin control internal and external spacing.
- Typography: Font size, weight, and color control text appearance.
- Dimensions: Width, height, and flex determine element sizing.
- Platform differences: Some visual properties behave differently across Android and iOS.
13. React Native Development Tools
| Tool |
Purpose |
| Node.js |
Provides the JavaScript runtime used by common development tooling. |
| npm or Yarn |
Installs and manages project dependencies. |
| Expo |
Provides tools and services that simplify many React Native development workflows. |
| Android Studio |
Provides Android SDK tools and an Android emulator. |
| Xcode |
Provides iOS development tools and simulators on supported macOS systems. |
| Visual Studio Code |
Popular code editor for JavaScript and TypeScript development. |
| React Native DevTools |
Helps inspect and debug supported React Native applications. |
| Git |
Tracks source-code changes and supports collaboration. |
14. Creating a React Native Project
One common starting point is Expo, which provides a streamlined way to create and run React Native projects.
14.1 Basic Setup Steps
- Install a supported Node.js version.
- Create a project using the current Expo project creation instructions.
- Open the generated project folder in a code editor.
- Install dependencies if required by the selected setup.
- Start the development server using the project scripts.
- Run the application in Expo Go when supported, or use an emulator or development build.
- Modify the application code and verify the changes.
14.2 Example Commands
npx create-expo-app@latest MyFirstApp
cd MyFirstApp
npx expo start
These commands illustrate a typical Expo workflow. Exact setup requirements can vary with the current Expo SDK, project template, and development environment.
15. React Native State and Props
15.1 What Are Props?
Props are values passed from a parent component to a child component. They help create reusable components that display different data.
function Greeting({ name }) {
return <Text>Hello, {name}!</Text>;
}
15.2 What Is State?
State represents data managed by a component that can change over time. Updating state causes React to render the relevant interface again.
const [count, setCount] = React.useState(0);
15.3 Props vs. State
| Props |
State |
| Passed into a component. |
Managed within a component or through a state-management system. |
| Used to configure a component. |
Used to track changing application data. |
| Should be treated as read-only by the receiving component. |
Updated through the appropriate state-management mechanism. |
16. React Native Navigation
Navigation enables users to move between screens, such as Home, Login, Product Details, Cart, and Profile. React Native applications commonly use navigation libraries to implement stacks, tabs, drawers, and other navigation patterns.
16.1 Common Navigation Patterns
- Stack navigation: Moves forward to a screen and allows returning to previous screens.
- Tab navigation: Switches between primary sections of an application.
- Drawer navigation: Provides a side menu for accessing application sections.
16.2 Example Application Flow
Login Screen
|
v
Home Screen
| |
v v
Products Profile
|
v
Product Details
|
v
Shopping Cart
17. API Integration in React Native
API integration allows a mobile application to communicate with a backend service to retrieve or submit information. Applications commonly use APIs for authentication, product data, booking details, notifications, and user profiles.
17.1 Example Using Fetch
async function loadPosts() {
try {
const response = await fetch(
'https://jsonplaceholder.typicode.com/posts'
);
if (!response.ok) {
throw new Error('Failed to fetch posts');
}
const posts = await response.json();
return posts;
} catch (error) {
console.error('API request failed:', error);
return [];
}
}
17.2 Important API Concepts
- HTTP methods such as GET, POST, PUT, PATCH, and DELETE.
- JSON request and response data.
- Authentication tokens and secure credential handling.
- Loading indicators and error messages.
- Network timeouts, retries, and offline scenarios.
- Environment-specific API configuration.
18. Testing and Debugging React Native Applications
18.1 Testing
Testing helps verify that an application behaves as expected. React Native projects may use unit tests, component tests, integration tests, and end-to-end tests.
18.2 Debugging
Developers can use supported debugging tools, logs, breakpoints, emulators, and device testing to investigate application problems.
18.3 Common Issues and Solutions
| Problem |
Possible Solution |
| Dependencies fail to install |
Check the Node.js version, package manager, dependency compatibility, and error output. |
| Application does not start |
Review terminal logs, development server output, and project configuration. |
| API request fails |
Check the network connection, endpoint, server response, and authentication. |
| Layout differs between platforms |
Test on Android and iOS and adjust platform-specific styling when necessary. |
| List performance is poor |
Use FlatList for long lists and review rendering behavior and item complexity. |
| Native module is unavailable |
Verify library compatibility and whether a native rebuild or development build is required. |
19. Best Practices for React Native Development
- Organize code into reusable components and logical modules.
- Use TypeScript when its type checking benefits the project.
- Keep components focused and avoid unnecessarily complex functions.
- Use appropriate state-management patterns for the application's size.
- Handle loading, error, empty, and success states in user interfaces.
- Protect authentication tokens and sensitive information.
- Validate user input on both the client and server when appropriate.
- Test on real devices and emulators across supported platforms.
- Choose maintained dependencies and review their permissions and security.
- Optimize large lists, images, animations, and expensive rendering operations.
- Follow accessibility guidelines for labels, touch targets, and readable content.
- Keep dependencies and platform build tools compatible with the project's React Native version.
20. Career Opportunities with React Native
React Native skills can support careers in mobile application development, cross-platform engineering, frontend development, and software product development.
20.1 Relevant Job Roles
- React Native Developer
- Mobile Application Developer
- Cross-Platform App Developer
- JavaScript Developer
- Frontend Developer with mobile development skills
- Software Engineer – Mobile Applications
20.2 Skills to Learn Alongside React Native
- JavaScript fundamentals and modern ES features.
- React components, props, state, and hooks.
- TypeScript fundamentals.
- Mobile navigation and responsive layouts.
- REST APIs and asynchronous programming.
- Git and collaborative development.
- Testing, debugging, and application performance.
- App signing, builds, and publishing workflows.
21. Practical Exercises
- Create a screen that displays your name and a short introduction.
- Build a counter using useState and a Pressable component.
- Create a login form with email and password fields.
- Display a list of products using FlatList.
- Fetch sample data from a public API and display loading and error states.
- Create a multi-screen application with stack or tab navigation.
- Build a simple shopping application with product cards and a cart screen.
- Test the application on Android and iOS environments where available.
22. Interview Questions and Answers
Q1. What is React Native?
Answer: React Native is an open-source framework for building mobile applications using React and JavaScript or TypeScript with native platform UI components.
Q2. Who developed React Native?
Answer: React Native was introduced by Facebook, now Meta.
Q3. Is React Native the same as React.js?
Answer: No. React.js is primarily used for web interfaces, while React Native is used to build mobile applications with native UI components.
Q4. Does React Native use HTML?
Answer: No. React Native uses components such as View and Text rather than standard HTML elements such as div and p.
Q5. Can React Native build both Android and iOS apps?
Answer: Yes. Developers can share much of their code between Android and iOS, although some platform-specific code may be necessary.
Q6. What is Fast Refresh?
Answer: Fast Refresh updates many changes in the application during development without requiring a complete restart.
Q7. What is a component in React Native?
Answer: A component is a reusable building block of the interface, such as a button, header, screen, or product card.
Q8. What is the difference between props and state?
Answer: Props are passed to a component, while state stores changing data managed by a component or an appropriate state-management system.
Q9. What is the purpose of FlatList?
Answer: FlatList efficiently renders scrollable lists, particularly when working with larger collections of data.
Q10. Can React Native access device features?
Answer: Yes. It can access supported device features through built-in APIs, third-party libraries, or custom native modules.
Q11. What is Expo?
Answer: Expo is a set of tools and services that simplifies many parts of React Native development, testing, and building.
Q12. Is React Native suitable for every mobile application?
Answer: No single framework is ideal for every project. React Native is suitable for many applications, but highly specialized graphics, platform-specific features, and performance-critical workloads may require additional native development.
23. Quick Revision Checklist
- Understand the definition and purpose of React Native.
- Know the difference between React.js and React Native.
- Understand cross-platform development and code reuse.
- Learn View, Text, Image, TextInput, Pressable, ScrollView, and FlatList.
- Understand props, state, and React hooks.
- Learn basic layouts and styling.
- Understand navigation and API integration.
- Practice development setup with Expo or another supported workflow.
- Learn debugging, testing, and performance optimization.
- Build a small application to demonstrate your skills.
24. Conclusion
React Native is a practical framework for building Android and iOS applications using React and JavaScript or TypeScript. Its component-based architecture, code-sharing capabilities, development tools, and access to native platform features make it a useful option for many mobile projects.
To learn React Native effectively, begin with JavaScript fundamentals and React concepts, then practice mobile layouts, state management, navigation, API integration, testing, and deployment. Building real projects is one of the best ways to strengthen your skills and prepare for mobile development opportunities.
Explore the course: React Native Training at JustAcademy
Register for a course demo: Book Your Course Demo