Giter Club home page Giter Club logo

Comments (6)

iway1 avatar iway1 commented on August 16, 2024 1

fixed in v1.4.3, thanks for the repro

from react-ts-form.

iway1 avatar iway1 commented on August 16, 2024 1

going to revert for now then, will look into this some more

from react-ts-form.

ingadi avatar ingadi commented on August 16, 2024 1

Before the fix my hacky work around was skipping the default values prop altogether and using the reset function inside a useEffect to set the form defaults on mount. Didn't get any infinite loops so ¯_(ツ)_/¯

  const form = useForm<z.infer<typeof FormSchema>>();
  const { reset } = form;

  useEffect(() => reset({ text: "hello" }), [reset]);

  return (
    <div className="App">
      <Form
        form={form}
        schema={FormSchema}
        onSubmit={(data) => {
          console.log("Got the data");
          console.log(data);
        }}
        renderAfter={() => <button>Submit</button>}
        // defaultValues={{
        //   text: "hello"
        // }}
      />
    </div>
  );

from react-ts-form.

iway1 avatar iway1 commented on August 16, 2024 1

That's what I should've done first =D.

Just released v1.4.5 with this included

from react-ts-form.

ingadi avatar ingadi commented on August 16, 2024

Just upgraded, works great but now getting the warning below... 'Cannot update a component (...) while rendering a different component (...)

warning

from react-ts-form.

iway1 avatar iway1 commented on August 16, 2024

you can use this for now:

useForm({
  defaultValues: {}
})

I'm not sure there's a way to make it work with the prop if that didn't work, but I'll try.

If not, I'll update the documentation in "Accessing Form State" to mention this, maybe add a warning if defaultValues and prop are both passed

from react-ts-form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.