Skip to content

Commit ebb8afc

Browse files
committed
Remove null check
1 parent d68d6e9 commit ebb8afc

2 files changed

Lines changed: 42 additions & 42 deletions

File tree

packages/react-reconciler/src/ReactFiberCommitWork.new.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,30 +288,30 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
288288
const ref = current.ref;
289289
const refCleanup = current.refCleanup;
290290

291-
if (typeof refCleanup === 'function') {
292-
try {
293-
if (shouldProfile(current)) {
294-
try {
295-
startLayoutEffectTimer();
291+
if (ref !== null) {
292+
if (typeof refCleanup === 'function') {
293+
try {
294+
if (shouldProfile(current)) {
295+
try {
296+
startLayoutEffectTimer();
297+
refCleanup();
298+
} finally {
299+
recordLayoutEffectDuration(current);
300+
}
301+
} else {
296302
refCleanup();
297-
} finally {
298-
recordLayoutEffectDuration(current);
299303
}
300-
} else {
301-
refCleanup();
302-
}
303-
} catch (error) {
304-
captureCommitPhaseError(current, nearestMountedAncestor, error);
305-
} finally {
306-
// `refCleanup` has been called. Nullify all references to it to prevent double invocation.
307-
current.refCleanup = null;
308-
const finishedWork = current.alternate;
309-
if (finishedWork != null) {
310-
finishedWork.refCleanup = null;
304+
} catch (error) {
305+
captureCommitPhaseError(current, nearestMountedAncestor, error);
306+
} finally {
307+
// `refCleanup` has been called. Nullify all references to it to prevent double invocation.
308+
current.refCleanup = null;
309+
const finishedWork = current.alternate;
310+
if (finishedWork != null) {
311+
finishedWork.refCleanup = null;
312+
}
311313
}
312-
}
313-
} else if (ref !== null) {
314-
if (typeof ref === 'function') {
314+
} else if (typeof ref === 'function') {
315315
let retVal;
316316
try {
317317
if (shouldProfile(current)) {

packages/react-reconciler/src/ReactFiberCommitWork.old.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,30 +288,30 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
288288
const ref = current.ref;
289289
const refCleanup = current.refCleanup;
290290

291-
if (typeof refCleanup === 'function') {
292-
try {
293-
if (shouldProfile(current)) {
294-
try {
295-
startLayoutEffectTimer();
291+
if (ref !== null) {
292+
if (typeof refCleanup === 'function') {
293+
try {
294+
if (shouldProfile(current)) {
295+
try {
296+
startLayoutEffectTimer();
297+
refCleanup();
298+
} finally {
299+
recordLayoutEffectDuration(current);
300+
}
301+
} else {
296302
refCleanup();
297-
} finally {
298-
recordLayoutEffectDuration(current);
299303
}
300-
} else {
301-
refCleanup();
302-
}
303-
} catch (error) {
304-
captureCommitPhaseError(current, nearestMountedAncestor, error);
305-
} finally {
306-
// `refCleanup` has been called. Nullify all references to it to prevent double invocation.
307-
current.refCleanup = null;
308-
const finishedWork = current.alternate;
309-
if (finishedWork != null) {
310-
finishedWork.refCleanup = null;
304+
} catch (error) {
305+
captureCommitPhaseError(current, nearestMountedAncestor, error);
306+
} finally {
307+
// `refCleanup` has been called. Nullify all references to it to prevent double invocation.
308+
current.refCleanup = null;
309+
const finishedWork = current.alternate;
310+
if (finishedWork != null) {
311+
finishedWork.refCleanup = null;
312+
}
311313
}
312-
}
313-
} else if (ref !== null) {
314-
if (typeof ref === 'function') {
314+
} else if (typeof ref === 'function') {
315315
let retVal;
316316
try {
317317
if (shouldProfile(current)) {

0 commit comments

Comments
 (0)