Home / Function/ finishEventHandler() — react Function Reference

finishEventHandler() — react Function Reference

Architecture documentation for the finishEventHandler() function in ReactDOMUpdateBatching.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  bbab8714_5482_7756_d9d1_07b4655458f7["finishEventHandler()"]
  0d9ca2c0_8ba8_d861_ef7c_cea0ecdd2aa3["ReactDOMUpdateBatching.js"]
  bbab8714_5482_7756_d9d1_07b4655458f7 -->|defined in| 0d9ca2c0_8ba8_d861_ef7c_cea0ecdd2aa3
  f9e9db51_d79e_2bec_6b9a_825840efe3e5["batchedUpdates()"]
  f9e9db51_d79e_2bec_6b9a_825840efe3e5 -->|calls| bbab8714_5482_7756_d9d1_07b4655458f7
  569171b2_86a8_e848_2d37_406ee0e7f9af["needsStateRestore()"]
  bbab8714_5482_7756_d9d1_07b4655458f7 -->|calls| 569171b2_86a8_e848_2d37_406ee0e7f9af
  6a30e1eb_6af5_eaa5_dadc_818db12c8f9b["restoreStateIfNeeded()"]
  bbab8714_5482_7756_d9d1_07b4655458f7 -->|calls| 6a30e1eb_6af5_eaa5_dadc_818db12c8f9b
  style bbab8714_5482_7756_d9d1_07b4655458f7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/events/ReactDOMUpdateBatching.js lines 27–44

function finishEventHandler() {
  // Here we wait until all updates have propagated, which is important
  // when using controlled components within layers:
  // https://github.com/facebook/react/issues/1698
  // Then we restore state of any controlled component.
  const controlledComponentsHavePendingUpdates = needsStateRestore();
  if (controlledComponentsHavePendingUpdates) {
    // If a controlled event was fired, we may need to restore the state of
    // the DOM node back to the controlled value. This is necessary when React
    // bails out of the update without touching the DOM.
    // TODO: Restore state in the microtask, after the discrete updates flush,
    // instead of early flushing them here.
    // @TODO Should move to flushSyncWork once legacy mode is removed but since this flushSync
    // flushes passive effects we can't do this yet.
    flushSyncWork();
    restoreStateIfNeeded();
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does finishEventHandler() do?
finishEventHandler() is a function in the react codebase, defined in packages/react-dom-bindings/src/events/ReactDOMUpdateBatching.js.
Where is finishEventHandler() defined?
finishEventHandler() is defined in packages/react-dom-bindings/src/events/ReactDOMUpdateBatching.js at line 27.
What does finishEventHandler() call?
finishEventHandler() calls 2 function(s): needsStateRestore, restoreStateIfNeeded.
What calls finishEventHandler()?
finishEventHandler() is called by 1 function(s): batchedUpdates.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free