Skip to content

v3.0.0

Compare
Choose a tag to compare
@AlemTuzlak AlemTuzlak released this 26 Oct 11:15
· 109 commits to main since this release
511c0bb

Form data submission rework

Earlier versions of remix-hook-form were using the following method to store formData to be sent to the server:

const data = yourClientData;
const formData = new FormData();
formData.set("formData", JSON.stringify(data));
submit(formData);

The problems with this approach were two fold:

  • it caused URL's to be very ugly if used in combination with GET
  • it didn't allow you to submit files

Well I've decided to do a complete rework and changed it to work like so:

const data = yourClientData;
const formData = new FormData();
Object.entries(data).map(helper)
submit(formData);

The important thing in the change is that it converts arrays, objects, numbers and booleans to strings before setting it into form data because it supports only string but another thing is that it appends files now so you can do file submissions with remix-hook-form.

File upload support

This has been requested for a while and has been added with this release. The only caveat is that you need to handle the file parsing on the server yourself. Remix-hook-form could, but won't provide a custom implementation for unstable_parseMultiPartFormData but that could lead to issues where the package doesn't support every deployment target so you will have to handle this part on your own!

What's Changed

Full Changelog: v2.0.0...v3.0.0