Controlled components are form elements whose values are fully managed by React state. In React Native, inputs like TextInput, Switch, and CheckBox become predictable when their value comes directly from state.
A controlled component binds its value prop to state and updates that state on every change event. In React Native, this is commonly done using useState with onChangeText.
// Controlled TextInput example in React Native
import React, { useState } from "react";
import { View, Text, TextInput } from "react-native";
export default function App() {
const [name, setName] = useState("");
return (
<View>
<Text>Enter your name:</Text>
<TextInput
value={name}
onChangeText={setName}
placeholder="Type here"
/>
<Text>You typed: {name}</Text>
</View>
);
}
As the user types into the input field, the state updates instantly. The displayed text below the input always matches the current state value.
State flow in a controlled component:
onChangeText firesType in the phone screen to see how State drives the UI.
Current Value:
const [email, setEmail] = useState("");
// Current State Data:
{
"email": ""
}