React Native is a popular JavaScript framework used to build mobile applications for Android and iOS using a single codebase. It allows developers to create real native mobile apps using familiar technologies like JavaScript and React.
React Native applications are written using functional components. Instead of HTML tags, React Native uses components like View, Text, and Button which map directly to native UI elements.
// Basic React Native component
import React from "react";
import { View, Text } from "react-native";
export default function App() {
return (
<View>
<Text>Hello React Native</Text>
</View>
);
}
The above code renders a simple mobile screen displaying the text “Hello React Native”. The View acts as a container and Text displays readable content on the screen.
The following demonstrates how changing state updates UI instantly.
// Interactive counter example
import React, { useState } from "react";
import { View, Text, Button } from "react-native";
export default function App() {
const [count, setCount] = useState(0);
return (
<View>
<Text>Count: {count}</Text>
<Button title="Increase" onPress={() => setCount(count + 1)} />
</View>
);
}