Remove unnecessary `typeof` checks (#13196)
This aligns with #10351 which removed extra check on `injectInternals`.
jddxf committed
Jul 18, 2018 at 03:18 UTC
6d3e2628809b94b334551344b4f1fe1c79c16e5b
3 files changed
+4
-6
packages/react-reconciler/src/ReactFiberCommitWork.js
+1
-3
@@ -398,9 +398,7 @@ function commitDetachRef(current: Fiber) {
398
// deletion, so don't let them throw. Host-originating errors should
399
// interrupt deletion, so it's okay
400
function commitUnmount(current: Fiber): void {
401
- if (typeof onCommitUnmount === 'function') {
402
- onCommitUnmount(current);
403
- }
401
+ onCommitUnmount(current);
402
403
switch (current.tag) {
404
case ClassComponent: {
packages/react-reconciler/src/ReactFiberScheduler.js
+1
-3
@@ -700,9 +700,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
700
isWorking = false;
701
stopCommitLifeCyclesTimer();
702
stopCommitTimer();
703
- if (typeof onCommitRoot === 'function') {
704
- onCommitRoot(finishedWork.stateNode);
705
- }
703
+ onCommitRoot(finishedWork.stateNode);
704
if (__DEV__ && ReactFiberInstrumentation.debugTool) {
705
ReactFiberInstrumentation.debugTool.onCommitWork(finishedWork);
706
}
packages/react/src/__tests__/ReactProfiler-test.internal.js
+2
@@ -37,6 +37,8 @@ function loadModules({
37
const mockDevToolsForTest = () => {
38
jest.mock('react-reconciler/src/ReactFiberDevToolsHook', () => ({
39
injectInternals: () => {},
40
+ onCommitRoot: () => {},
41
+ onCommitUnmount: () => {},
42
isDevToolsPresent: true,
43
}));
44
};