Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda