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

145
Views
Error transmitting callback function as props

enter image description here/* I take only the important part of code */

Parent: */Here I create logic for my function */ `

const [allNoc,setAllNoc] = useState(0);

const allNocFunc = value => {
    console.log(value);
    setAllNoc(value);
  };`

*/In return I have my component with props */

<SellectAllNoc dataList={resultDataList} allNocFunc={allNocFunc} />

Child:

function SellectAllNoc(dataList,allNocFunc) {const handleChange = () => {allNocFunc(2);};

I want to sent value from child to parent by callback function

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If "Child" is meant to be a React component, this is not how you destructure props:

function SellectAllNoc(dataList,allNocFunc) {

This is:

function SellectAllNoc({ dataList, allNocFunc }) {

Basically, all of the props are passed to the component as a single object, with the prop keys/values being the properties on that object. So in your code the dataList variable has two properties on it, called dataList and allNocFunc. And in your code the allNocFunc variable isn't a function. (I actually don't know if components receive a second argument in React, I've never used one. So it may be undefined, or may be some unexpected 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!