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

198
Visualizações
Why checkbox not getting checked even when its true?

I have used checkbox in my react application. I don't know why it is not getting checked/unchecked on click. I am using Hashmap to get true/false and passing same to the checked attribute.

In below code - variable "checkBoxSelectedHash" is hashmap having value true/false.

Note: I did checked the console of variable "checkBoxSelectedHash" also It is getting changed correctly But don't know why it is not getting reflected in checkbox.

                <tbody>

                        {reservationSourceDetail ? reservationSourceDetail.map((value, index) => (

                          <tr key={index}>
                            <td>{value.ota_name}</td>
                            {rateCodeDetail ? rateCodeDetail.map((val) => (

                              <td style={{ textAlign: "center" }}>

                                <input className="form-check-input" type="checkbox"
                                checked={checkBoxSelectedHash[value.ota_id+"_"+val.name]}
                                onChange={() => handleCheckBox(value.ota_id, val.name)}
                                /> 
                                
                              </td>

                            )) : ""}

                          </tr>
                        )) : ""

                        }
                      </tbody>

For on change handleCheckBox function below :

const handleCheckBox = (ota_id, rate_code_name) => {

    let temp_checkBoxSelectedHash = checkBoxSelectedHash;

    temp_checkBoxSelectedHash[ota_id+"_"+rate_code_name] = !temp_checkBoxSelectedHash[ota_id+"_"+rate_code_name];

    setCheckBoxSelectedHash(temp_checkBoxSelectedHash);
  }
about 4 years ago · Juan Pablo Isaza
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