Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update field value automatically #728

Closed
wants to merge 3 commits into from
Closed

Conversation

edmundhung
Copy link
Owner

Fix #600.

This is an attempt to remove the need of passing the key to each input manually by updating the fields value automatically. It means:

  1. No more warnings from React when spreading the result of getInputProps(), getSelectProps() or getTextareaProps() as it will no longer include a key.
  2. The name will become the only metadata required to be set on your inputs. The initalValue is required only if you care about progressive enhancement.

The main challenge of this change is that Conform will trigger a re-render only when the subscribed metadata is changed and so we don't have a single place that will always re-render and runs the side effect we need. This PR resolves it by running the side effect everywhere we made a subscription and update the relevant fields only if the initialValue is subscribed.

Copy link

changeset-bot bot commented Aug 3, 2024

⚠️ No Changeset found

Latest commit: 3f72eba

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

Copy link

cloudflare-workers-and-pages bot commented Aug 3, 2024

Deploying conform with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3f72eba
Status: ✅  Deploy successful!
Preview URL: https://d2c9f96f.conform.pages.dev
Branch Preview URL: https://field-side-effect.conform.pages.dev

View logs

@edmundhung
Copy link
Owner Author

Superseded by #729

@edmundhung edmundhung closed this Aug 3, 2024
@edmundhung edmundhung deleted the field-side-effect branch August 3, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning: A props object containing a "key" prop is being spread into JSX:
1 participant