Skip to content

Commit

Permalink
refactor to avoid optional chaining syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsavona committed Oct 20, 2021
1 parent e287fbc commit c8a2074
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
19 changes: 12 additions & 7 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2915,13 +2915,18 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
case LegacyHiddenComponent:
case OffscreenComponent: {
if (enableCache) {
const cache: Cache = current.memoizedState?.cachePool?.pool;
// Retain/release the cache used for pending (suspended) nodes.
// Note that this is only reached in the non-suspended/visible case:
// when the content is suspended/hidden, the retain/release occurs
// via the parent Suspense component (see case above).
if (cache != null) {
retainCache(cache);
if (
current.memoizedState !== null &&
current.memoizedState.cachePool !== null
) {
const cache: Cache = current.memoizedState.cachePool.pool;
// Retain/release the cache used for pending (suspended) nodes.
// Note that this is only reached in the non-suspended/visible case:
// when the content is suspended/hidden, the retain/release occurs
// via the parent Suspense component (see case above).
if (cache != null) {
retainCache(cache);
}
}
}
break;
Expand Down
19 changes: 12 additions & 7 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2915,13 +2915,18 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
case LegacyHiddenComponent:
case OffscreenComponent: {
if (enableCache) {
const cache: Cache = current.memoizedState?.cachePool?.pool;
// Retain/release the cache used for pending (suspended) nodes.
// Note that this is only reached in the non-suspended/visible case:
// when the content is suspended/hidden, the retain/release occurs
// via the parent Suspense component (see case above).
if (cache != null) {
retainCache(cache);
if (
current.memoizedState !== null &&
current.memoizedState.cachePool !== null
) {
const cache: Cache = current.memoizedState.cachePool.pool;
// Retain/release the cache used for pending (suspended) nodes.
// Note that this is only reached in the non-suspended/visible case:
// when the content is suspended/hidden, the retain/release occurs
// via the parent Suspense component (see case above).
if (cache != null) {
retainCache(cache);
}
}
}
break;
Expand Down

0 comments on commit c8a2074

Please sign in to comment.