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

136
Visualizações
State lost value in bootstrap table

I am using custom fields in react bootstrap table.

 {
  dataField: "hours",
  text: "# of Hours",
  sort: true,
  footer: "# of Hours",
  headerStyle: (colum, colIndex) => {
    return { width: "10%" };
  },
  formatter: (cellContent, row) => {
    return (
      <div className="form-row">
        <AvForm>
          <Controls.Input
            name="hours"
            type="text"
            placeholder="Enter Hours"
            value={rosterData.hours}
            handleChange={handleChange}
          />
        </AvForm>
      </div>
    );
  },
},

My handle change Function

    const [rosterData, setRosterData] = useState({
    S_time: "21:00",
    hours: "",
  });



 const handleChange = (evt) => {
    const value = evt.target.value;
    setRosterData({ ...rosterData, [evt.target.name]: value });
  };

When I enter the value in field, state set that value, but when I click on save button for using that value, state becomes empty.

Button for saving data

{
  dataField: "action",
  text: "Action",
  footer: "Action",
  isDummyField: true,
  formatter: (cellContent, row) => {
    return (
      <div>
        <AiFillSave
          style={{ color: "#0190d5", cursor: "pointer" }}
          onClick={() => submitRoster(row.id)}
        />
      </div>
    );
  },
},

function for save button

const submitRoster = (id) => {
const data = {
  id: id,
  S_time: rosterData.S_time,
  hours: rosterData.hours,
};
console.log("onclick Data=", data);
};

console while changing one field

console while changing other value

console when click on save button

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