Skip to content

Commit

Permalink
Profiler should only report stateful hooks that change between renders (
Browse files Browse the repository at this point in the history
facebook#24189)

The Profiler has an advanced feature that shows why a component re-rendered. In the case of props and (class) state, it shows the names of props/state values that changed between renders. For hooks, DevTools tries to detect which ones may been related to the update by comparing prev/next internal hook structures.

My initial implementation tried to detect all changed hooks. In hindsight this is confusing, because only stateful hooks (e.g. useState, useReducer, and useSyncExternalStore) can schedule an update. (Other types of hooks can change between renders, but in a reactive way.) This PR changes the behavior to only report hooks that scheduled the update.
  • Loading branch information
Brian Vaughn authored and zhengjitf committed Apr 15, 2022
1 parent 4e749f3 commit 9f414d9
Show file tree
Hide file tree
Showing 3 changed files with 523 additions and 442 deletions.
Loading

0 comments on commit 9f414d9

Please sign in to comment.