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

164
Vistas
how can I pass my remove function with a parameter inside InpuTime?

I'm trying to pass a remove function into the map with a parameter, but it's like I'm not using my function. What would be the correct way to call ''remove(i)'' inside InputTime in onRemove?

Component
    
    render() {
    const {remove} = this.props;

    return(
      <>
          <InputTime
            onRemove={() => remove(i)}
            {...this.props}
          />
      </>
    )
  }
}

// another class
  handlerRemove(){
    ...
  }
return(
   <Component remove={() => this.handlerRemove()} />
)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here you go with a solution

render() {
    const {remove} = this.props;


    return(
      <>
        
            <InputTime
              time={hour}
              onRemove={() => remove(i)}
              {...this.props}
            />
         
      </>
    )
  }
}

As you have done the destructing using const {values, remove} = this.props;, then you don't need to add this for prop function.

Current code onRemove={() => this.remove(i)}

Change you code to onRemove={() => remove(i)}

As the user change the code a bit, based on that the solution

Component
    
    render() {
    const {remove} = this.props;
    const arg = "test";

    return(
      <>
          <InputTime
            onRemove={() => remove(arg)}
            {...this.props}
          />
      </>
    )
  }
}

// another class
  handlerRemove(passedArg){
    console.log("passedArg", passedArg);
  }
return(
   <Component remove={this.handlerRemove} />
)
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