edmundhung / conform

A type-safe form validation library utilizing web fundamentals to progressively enhance HTML Forms with full support for server frameworks like Remix and Next.js.
https://conform.guide
MIT License
1.8k stars 101 forks source link

fix: TypeError on creating properties on immutable objects #671

Open novikovfred opened 3 months ago

novikovfred commented 3 months ago

fix #670

changeset-bot[bot] commented 3 months ago

⚠️ No Changeset found

Latest commit: 69395d22622af67a0d5184d4c563f0683e25bbe2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

novikovfred commented 3 months ago

@edmundhung review pls

confix commented 3 weeks ago

Actually the check makes perfect sense to me. We were bitten by that today as well.

Someone updated a fieldset (object) via form.update with a string value instead of an object. Afterwards we want to set a property of the mentioned fieldset via a regular input field and the error occurs.

// state: { fieldset: { property: "aValue" }}
form.update({ name: "fieldset", value "a string" })
// state: { fieldset: "a string" }

// a change to the input below crashes with the same error
<input name="fieldset.property" />

We should report a warning as long as we're in development, though. We could end up in the very same situation by simply having a bug in our application.