Skip to content

Commit

Permalink
Tidy up early bailout logic at start of begin phase (#21852)
Browse files Browse the repository at this point in the history
* Extract early bailout to separate function

This block is getting hard to read so I moved it to a separate function.
I'm about to refactor the logic that wraps around this path.

Ideally this early bailout path would happen before the begin phase
phase. Perhaps during reconcilation of the parent fiber's children.

* Extract state and context check to separate function

The only reason we pass `updateLanes` to some begin functions is to
check if we can perform an early bail out. But this is also available
as `current.lanes`, so we can read it from there instead.

I think the only reason we didn't do it this way originally is because
components that have two phases — error and Suspense boundaries —
use `workInProgress.lanes` to prevent a bail out, since during the
initial render there is no `current`. But we can check the `DidCapture`
flag instead, which we use elsewhere to detect the second phase.
  • Loading branch information
acdlite authored Jul 29, 2021
1 parent d9dd965 commit 34308b5
Show file tree
Hide file tree
Showing 4 changed files with 520 additions and 490 deletions.
Loading

0 comments on commit 34308b5

Please sign in to comment.