0

for passing data from parent to child we can pass it as props like :

<Child data={data}/>

but i would like to send data from child to parent, note that am using functional components, i tried to send a callback function with data parameters as props

IN MY PARENT FUNCTION:

   const onSuccess = (data) => {    
    // DO THE FOLLOWING WITH DATA THAT AM TRYING TO GET
  }
 
<Child onSuccess={onSuccess)}/>

IN MY CHILD FUNCTION:

   const onResponse = (data) => {    
    props.onSuccess(data);
  }

so here i want a way to access my parameter data or any other way to get it from a child component, thanks a lot for your time.

larachiwnl
  • 337
  • 5
  • 10

0 Answers0