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

86
Vistas
Pass const present in other function as a props | React class component

I have this view which is in the Controller, and item is passed as a prop.

render () {
    if (this.view) {
        const { item } = this.props;
        return <ViewComponent 
            item = {item}
        />;
    }
}

I have this other function save() which creates and save the payload.

I need to pass this payload as well present it to the save function as a prop to my view so I can use it.

save () {
    const payload = constructPayloadFunction();
    createFunction({ payload });
}

How do I do that?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have to create a function in you Controller

public createFunction(payload){....}

and pass this as a prop to your ViewComponent

if (this.view) {
   const { item } = this.props;
   return <ViewComponent 
   item = {item}
   createFunction = {createFunction}
   />;
}

and finally, in your save function, just pass the result

const payload = constructPayloadFunction();
createFunction(payload);
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