Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda