Skip to content

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

@aweary

Description

@aweary

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions