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.
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
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>
);
}
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);
}
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.
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.
React Native provides components designed for mobile application interfaces.
These components are used to construct mobile screens.
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>
);
}
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
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.
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" />
);
}
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.
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>
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
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.
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.
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.
A typical API data flow looks like this:
React Native App
↓
HTTP Request
↓
Backend API
↓
Database
↓
JSON Response
↓
React Native State
↓
Mobile UI
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.
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.
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
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.
Mobile applications can access device capabilities through appropriate React Native APIs and libraries.
Examples include:
Some capabilities require platform permissions.
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.
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
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.
When an application has a problem, developers can inspect logs, errors and application behavior to identify the cause.
Common problems can occur in:
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.
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.
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
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.
Question: What is the basic working model of React Native?