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

142
Views
React Final Form Checkbox Not Resetting Values on Next.js Hot Reload

I'm using React Final Form checkboxes. When I make a change in my code, the nextjs does a hot reload, but the form values/data keeps the checkbox to be still truthy but the checkbox becomes unchecked. I thought if it reloads, it should reset the form?

So for example, if I have 2 items in a list with checkboxes, if I check 1 item, I'll have a length of 1, then when nextjs hot reloads, it looks like nothing is checked (which should be expected), but if I check the same item, it will add to the list with length of 2 items checked (1 from prior hot reload, and then another 1 after hot reload)

<Form
  onSubmit={onSubmitCheckbox}
  render={({ handleSubmit, submitting, values }) => (
    <form onSubmit={handleSubmit} className="">
      <button type="submit" disabled={submitting}>
        Delete multiple
      </button>
      <div>
        {posts.map((post, index) => {
          return (
            <div key={index}>
              <div>
                <Field
                  name="post"
                  type="checkbox"
                  component="input"
                  value={post}
                  // onChange={(event, value) =>
                  //   console.log("checked", event, value)
                  // }
                >
                  {({ input, meta }) => {
                    return (
                      <input
                        {...input}
                        onChange={(e) => {
                          input.onChange(e); //final-form's onChange
                          console.log("onChange", values);
                        }}
                      />
                    );
                  }}
                </Field>
              </div>
            </div>
          );
        })}
      </div>
    </form>
  )}
/>

Is this supposed to be expected behavior? Am I doing the checkboxes wrong?

const onSubmitCheckbox = (values) => {
  const { post } = values;
  console.log("submitting checkbox", post.length);
};

This is the onsubmit function and it will display 2 of the post items.

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!