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

166
Views
I want to set state of parent component from child component during onChangeText in react native?

Here I want to setName of parent component's state from child component while onCHangeText but it gives me "TypeError: setName is not a function. (In 'setName(text)', 'setName' is undefined)" error

Here is my Parent Component

const ProfileCreationScreen = () => {
    const [name, setName] = useState()
 


  const userSignup = async () => {
    try {
  
      firestore().collection('users').doc("androiduser_mobile89").set({
        name: name,
      });
      alert("Succesfully Created")
    } catch (error) {
      alert(error);
    }
  };


  return (
    <SafeAreaView>
      <Text>Create your account</Text>
      <Button
        mode="contained"
        onPress={() => userSignup()}>
        Sign Up
      </Button>
      <View style={{ display: "none" }}>
        <NameScreen setName={setName} />
      </View>
    </SafeAreaView>
  )
}

Here is my child component

export const NameScreen = ({ setName, navigation }) => {
return (
  <KeyboardAvoidingView
    enabled
    behavior="padding"
    style={styles.container}>
    <View>
      <Text style={styles.text}>Full Name</Text>
      <TextInput
        style={styles.textField}
        label="Enter your Full Name"
        underlineColor="#FF0074"
        outlineColor="red"
        value={text}
        onChangeText={(text) => setName(text)}
      />
      <Button mode="contained" style={styles.btn} onPress={() => alert(text)}>
        Next
      </Button>
    </View>
  </KeyboardAvoidingView>
);
about 4 years ago · Juan Pablo Isaza
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!