The onChange event of the TextInput component works differently in React Native than in a web browser. To obtain the text value directly, use the onChangeText prop rather than event.target.value. Here’s how to change your React Native code to handle this correctly

import React, { useState } from 'react';
import { View, TextInput } from 'react-native';
const App = () => {
  const [inputValue, setInputValue] = useState('');
  const handleInput = (text) => {
    setInputValue(text);
  };

  return (
      <TextInput
        value={inputValue}
        onChangeText={handleInput}
        placeholder="Enter text here"
      />
  );
};
export default App;

 
React Native text input handling is easier using onChangeText, which allows you to access the text value directly instead of interacting with the event object.

Support On Demand!

React Native