Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
React Native TextInput not updating state in a functional component using onhange

I am using a in a react native functional component and onChange the state does not seem to be updating for "name".

I am console logging the new state using useEffect to check whether or not the state is updated and it is returning undefined as if the input text was never set as the state "name"

function AddTask ()  {
    
    const [name, setName] = useState('');
  
    useEffect(() => {
        console.log(name),name;
        
    })

    const updateTaskInfo = event => setName(event.target.value);
    
        return (
             <TextInput
                  onChange={updateTaskInfo}
                  placeholder="Name"
                  value={name}
             />
 );
}

export default AddTask;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

use onChange like that event.nativeEvent.target.value

<TextInput onChange={ event => setName(event.nativeEvent.target.value) } />

or use onChangeText like that

<TextInput onChangeText ={ value => setName(value ) } />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!