Lesson 6 of 60 – How React Native Works
10%

How React Native Works

React Native allows developers to build mobile applications using JavaScript or TypeScript and React. Instead of creating the complete application interface using traditional web HTML elements, React Native uses React components that are mapped to platform UI capabilities.

Note: You do not need to understand every internal detail before starting React Native. At this stage, focus on understanding the basic flow: write React Native code, create components, render the interface, handle user interactions, communicate with native capabilities and run the application on a mobile platform.

1. Basic Working of React Native

A React Native application starts with JavaScript or TypeScript code that defines components and application logic.

React Native then uses that code to create and update the application's user interface and behavior.

JavaScript / TypeScript
          ↓
        React
          ↓
    React Native
          ↓
   Mobile Application

2. React Native Uses React

React Native uses the React programming model.

This means developers can create components and use concepts such as props, state, Hooks and JSX.

function App() {
    return (
        <View>
            <Text>Hello React Native</Text>
        </View>
    );
}

3. JavaScript Runs the Application Logic

JavaScript or TypeScript can contain the application's logic.

For example, JavaScript can control state changes, form processing, API requests and user interactions.

const [count, setCount] = useState(0);

function increaseCount() {
    setCount(count + 1);
}

4. Components Describe the UI

React Native applications are divided into components.

Each component can describe a part of the mobile interface.

function Welcome() {
    return (
        <View>
            <Text>Welcome Student</Text>
        </View>
    );
}

Components can be combined to create complete screens.

5. JSX Describes the Component Structure

JSX provides a readable way to describe the structure of a React Native component.

<View>
    <Text>Student Dashboard</Text>
    <Text>Welcome</Text>
</View>

JSX is written inside JavaScript or TypeScript files.

6. React Native Components

React Native provides components designed for mobile application interfaces.

  • View
  • Text
  • Image
  • TextInput
  • ScrollView
  • Pressable
  • FlatList

These components are used to construct mobile screens.

7. View and Text Example

A simple screen can be created by placing a Text component inside a View component.

import { View, Text } from "react-native";

function App() {
    return (
        <View>
            <Text>Hello Mobile App</Text>
        </View>
    );
}

8. Rendering the Root Component

A React Native application needs a root component from which the application interface begins.

The application's entry configuration starts the React Native application and renders the root component.

App
 ↓
Home Screen
 ↓
Components

9. Component Tree

React Native applications can be represented as a component tree.

App
 ├── Header
 ├── Content
 │    ├── StudentCard
 │    └── StudentList
 └── Footer

The root component contains child components, and those components can contain additional components.

10. Props Flow Through Components

Data can be passed from a parent component to a child component using props.

function Student({ name }) {
    return (
        <Text>{name}</Text>
    );
}

function App() {
    return (
        <Student name="Rahul" />
    );
}

11. State Changes Cause UI Updates

When state changes, React can re-render the relevant component so that the user interface reflects the new state.

const [count, setCount] = useState(0);

setCount(count + 1);

This makes it possible to create interactive mobile applications.

12. User Interaction

Users interact with a mobile application through actions such as pressing buttons, entering text and scrolling.

<Pressable
    onPress={() => setCount(count + 1)}
>
    <Text>Increase</Text>
</Pressable>

13. Event Handler Flow

An event can call a JavaScript function, which can then update state or perform another action.

User Press
    ↓
onPress
    ↓
JavaScript Function
    ↓
State Update
    ↓
UI Update

14. Styling the Interface

React Native uses a styling system to describe the appearance of components.

const styles = StyleSheet.create({
    title: {
        fontSize: 24,
        fontWeight: "bold",
        marginBottom: 10
    }
});

Styles can be applied to React Native components.

15. Flexbox Layout

React Native commonly uses Flexbox to arrange components on the screen.

container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center"
}

Flexbox helps create layouts that can adapt to different screen sizes.

16. API Requests

A React Native application can request information from a backend server using HTTP APIs.

fetch("https://example.com/api/students")
    .then(response => response.json())
    .then(data => console.log(data));

The returned data can then be stored in state and displayed in the UI.

17. API Data Flow

A typical API data flow looks like this:

React Native App
       ↓
    HTTP Request
       ↓
   Backend API
       ↓
    Database
       ↓
   JSON Response
       ↓
React Native State
       ↓
   Mobile UI

18. JSON Data

APIs commonly return data in JSON format.

{
    "id": 1,
    "name": "Rahul",
    "course": "React Native"
}

React Native can read this data and use it to display dynamic application content.

19. Navigation Between Screens

A real application normally contains multiple screens.

Navigation allows users to move between screens.

Login
  ↓
Home
  ↓
Profile
  ↓
Settings

Navigation is normally implemented using a suitable navigation library.

20. Local Storage

Applications sometimes need to save information locally on the device.

Storage solutions can be used for information such as preferences, cached data or application-specific local information.

Application
     ↓
Local Storage
     ↓
Device

21. Authentication Flow

A mobile application can communicate with a backend authentication service.

Login Form
    ↓
Authentication API
    ↓
Credentials Verified
    ↓
Authentication Result
    ↓
Home Screen

The exact authentication implementation depends on the backend and security architecture.

22. Device APIs

Mobile applications can access device capabilities through appropriate React Native APIs and libraries.

Examples include:

  • Camera
  • Location
  • Notifications
  • Media
  • Device information

Some capabilities require platform permissions.

23. Native Platform Interaction

React Native provides a JavaScript-based development model while allowing applications to interact with platform capabilities.

This is one of the important ideas behind React Native: developers work primarily with React and JavaScript while the application runs on mobile platforms.

24. Platform-Specific Code

Most application logic can be shared, but sometimes Android and iOS need different implementations.

React Native provides platform APIs and platform-specific file patterns to handle these differences.

Android
   ↓
Android-specific behavior

iOS
   ↓
iOS-specific behavior

25. Development and Testing

Developers can run React Native applications during development and test them on supported development environments and physical devices.

Testing helps identify UI, navigation, API and platform-specific issues.

26. Debugging Application Problems

When an application has a problem, developers can inspect logs, errors and application behavior to identify the cause.

Common problems can occur in:

  • JavaScript code
  • Component rendering
  • State management
  • Navigation
  • API requests
  • Platform configuration

27. Complete Application Flow

User
 ↓
Mobile Screen
 ↓
React Native Component
 ↓
Event Handler
 ↓
State / Business Logic
 ↓
API Request
 ↓
Backend
 ↓
Database
 ↓
JSON Response
 ↓
React Native State
 ↓
Updated UI

This flow represents a common pattern for data-driven mobile applications.

28. Example: Student Application

Suppose we create a student management mobile application.

Login Screen
     ↓
Student Dashboard
     ↓
API Request
     ↓
PHP Backend
     ↓
MySQL Database
     ↓
Student Data
     ↓
React Native UI

The same architecture can be adapted for education, business, e-commerce and other applications.

29. React Native Working Model

The overall React Native development model can be understood as:

Write JavaScript / TypeScript
             ↓
       Create Components
             ↓
          JSX UI
             ↓
       React Rendering
             ↓
      Mobile UI Updates
             ↓
 User Interaction / Events
             ↓
 State / API / Device Logic
             ↓
       Updated Interface

30. Complete React Native Workflow

A complete React Native application can be developed through the following workflow:

Plan Application
       ↓
Create Project
       ↓
Create Components
       ↓
Design Screens
       ↓
Add Navigation
       ↓
Manage State
       ↓
Connect APIs
       ↓
Add Storage
       ↓
Add Authentication
       ↓
Use Device Features
       ↓
Test & Debug
       ↓
Build Application

Understanding this workflow will make the advanced React Native lessons easier to follow.

📌 Key Points

  • React Native applications are built using JavaScript or TypeScript and React.
  • Components describe the mobile user interface.
  • JSX is used to describe component structures.
  • Props pass data between components.
  • State changes can cause the UI to update.
  • User events can trigger JavaScript functions and state changes.
  • React Native uses Flexbox for many layout requirements.
  • Applications can communicate with backend APIs.
  • Navigation allows users to move between screens.
  • React Native can interact with device capabilities through appropriate APIs and libraries.
  • Platform-specific code can be used when Android and iOS require different behavior.

🧠 Quick Quiz

Question: What is the basic working model of React Native?