Get rid of ugly and difficult to follow breaks in switch
Because pattern matching or something.
Sebastian Markbage committed
Jun 7, 2016 at 17:05 UTC
40180c4b268654d793289cc567b9e5bcb91766ad
1 file changed
+5
-6
src/renderers/shared/fiber/ReactFiberBeginWork.js
+5
-6
@@ -97,16 +97,16 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
97
switch (workInProgress.tag) {
98
case IndeterminateComponent:
99
mountIndeterminateComponent(current, workInProgress);
100
- break;
100
+ return workInProgress.child;
101
case FunctionalComponent:
102
updateFunctionalComponent(current, workInProgress);
103
- break;
103
+ return workInProgress.child;
104
case ClassComponent:
105
console.log('class component', workInProgress.input.type.name);
106
- break;
106
+ return workInProgress.child;
107
case HostComponent:
108
updateHostComponent(current, workInProgress);
109
- break;
109
+ return workInProgress.child;
110
case CoroutineHandlerPhase:
111
// This is a restart. Reset the tag to the initial phase.
112
workInProgress.tag = CoroutineComponent;
@@ -121,7 +121,7 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
121
workInProgress.child
122
);
123
}
124
- break;
124
+ return workInProgress.child;
125
case YieldComponent:
126
// A yield component is just a placeholder, we can just run through the
127
// next one immediately.
@@ -135,7 +135,6 @@ function beginWork(current : ?Fiber, workInProgress : Fiber) : ?Fiber {
135
default:
136
throw new Error('Unknown unit of work tag');
137
}
138
- return workInProgress.child;
138
}
139
140
exports.beginWork = beginWork;