What is TextInput in React Native?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex React Native topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
TextInput is the component for capturing text from the user. It maps to UITextField/UITextView (iOS) and EditText (Android). Basic usage: import { TextInput } from "react-native"; const [text, setText] = useState(""); <TextInput value={text} onChangeText={setText} placeholder="Enter text..." style={styles.input} />. Key props: value — controlled value; onChangeText — callback receiving new text; placeholder — placeholder text; placeholderTextColor; secureTextEntry — password field (hides input); keyboardType: "default" | "numeric" | "email-address" | "phone-pad" | "decimal-pad" — what keyboard to show; autoCapitalize: "none" | "sentences" | "words" | "characters"; autoCorrect: {false} — disable autocorrect; multiline: {true} — multiple lines; numberOfLines — initial height for multiline; maxLength — character limit; returnKeyType: "done" | "search" | "send" | "next" — keyboard's return button label; onSubmitEditing — fires when return key is pressed; blurOnSubmit: {false} — don't blur when submitting multiline; editable: {false} — read-only. Focusing programmatically: const inputRef = useRef(null); inputRef.current.focus(); inputRef.current.blur(); <TextInput ref={inputRef} />. Styling: on iOS, TextInput has no default border. Add one via style: borderWidth: 1, borderColor: "#ccc", borderRadius: 8, padding: 12. On Android, has default underline — use underlineColorAndroid="transparent" to remove.
Common Mistake
Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your React Native experience.