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

ReactDOM.requestFormReset #28809

Merged
merged 1 commit into from
Apr 10, 2024
Merged

ReactDOM.requestFormReset #28809

merged 1 commit into from
Apr 10, 2024

Commits on Apr 10, 2024

  1. ReactDOM.requestFormReset

    This adds a React DOM method called requestFormReset that schedules a
    form reset to occur when the current transition completes.
    
    Internally, it's the same method that's called automatically whenever
    a form action is submitted. It only affects uncontrolled form inputs.
    See facebook#28804 for details.
    
    The reason for the public API is so UI libraries can implement their
    own action-based APIs and maintain the form-resetting behavior,
    something like this:
    
    ```js
    function onSubmit(event) {
      // Disable default form submission behavior
      event.preventDefault();
      const form = event.target;
      startTransition(async () => {
        // Request the form to reset once the action
        // has completed
        requestFormReset(form);
    
        // Call the user-provided action prop
        await action(new FormData(form));
      })
    }
    ```
    acdlite committed Apr 10, 2024
    Configuration menu
    Copy the full SHA
    55fec73 View commit details
    Browse the repository at this point in the history