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

263
Views
Pass SetState from parent component to a child component in React Native

In React js I would pass setState like below from parent components to child components, however in React Native setABC is undefined. What's the best way to achieve the below in React Native?

Parent.js:

function Parent(){


    const [ABC, setABC] = useState();



     return(
        <routes>
           <route path="/child" element={<Child setABC={setABC} />} />
        </routes>
     );

}


export default Parent;

Child.js:

function Child({setABC}){

    let doSomeStuff = () =>{

        setABC("ABC");

    }

 }

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

0

the problem is not related to react-native you passed the prop as setState in parent.js

<Child setState={setABC} />

and received it as setABC function Child({setABC}){

it should be like this

function Child({setState}) {
...
}

or change the prop name in Parent.js to match Chlid.js

<route path="/child" element={<Child setABC={setABC} />} />
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!