Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!