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

Fire change events for changes made to inputs before hydration #12955

Closed
aweary opened this issue May 31, 2018 · 4 comments
Closed

Fire change events for changes made to inputs before hydration #12955

aweary opened this issue May 31, 2018 · 4 comments

Comments

@aweary
Copy link
Contributor

aweary commented May 31, 2018

Currently when hydrating server-rendered markup we ignore changes the user makes before hydration. We also don't reset their changes once hydration finishes. The motivation there was likely to avoid losing user input. See this test:

https://github.com/facebook/react/blob/master/packages/react-dom/src/__tests__/ReactDOMServerIntegrationForms-test.js#L543-L552

The problem with that is that it assumes the value will continue to be changed after hydration completes (e.g., a user keeps typing). If they don't, then the DOM and React will be out of sync.

We should try to detect if there have been any changes made to an input when hydrating, and if so dispatch a change event so that the component is notified of the new value.

See #12939 for some more discussion.

@asiniy
Copy link

asiniy commented Jun 11, 2018

It's promising to be extremely difficult to me, but I'm taking this one

@stale
Copy link

stale bot commented Jan 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

@stale stale bot added the Resolution: Stale Automatically closed due to inactivity label Jan 10, 2020
@stale
Copy link

stale bot commented Jan 19, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

@joliss
Copy link

joliss commented Oct 25, 2022

@acdlite I was wondering if it could be worth reopening this issue? This is still a problem for me on the latest React 18.2.0, when hydrating a component with an <input> field via Next.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants