|
41 | 41 | PlacementAndUpdate,
|
42 | 42 | Deletion,
|
43 | 43 | Callback,
|
44 |
| - PlacementAndCallback, |
45 |
| - UpdateAndCallback, |
46 |
| - PlacementAndUpdateAndCallback, |
47 |
| - DeletionAndCallback, |
48 | 44 | Err,
|
49 |
| - PlacementAndErr, |
50 |
| - UpdateAndErr, |
51 |
| - PlacementAndUpdateAndErr, |
52 |
| - DeletionAndErr, |
53 |
| - PlacementAndCallbackAndErr, |
54 |
| - UpdateAndCallbackAndErr, |
55 |
| - PlacementAndUpdateAndCallbackAndErr, |
56 |
| - DeletionAndCallbackAndErr, |
57 | 45 | } = require('ReactTypeOfSideEffect');
|
58 | 46 |
|
59 | 47 | var {
|
@@ -173,44 +161,37 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) {
|
173 | 161 | // ref unmounts.
|
174 | 162 | let effectfulFiber = finishedWork.firstEffect;
|
175 | 163 | while (effectfulFiber) {
|
176 |
| - switch (effectfulFiber.effectTag) { |
177 |
| - case Placement: |
178 |
| - case PlacementAndCallback: |
179 |
| - case PlacementAndErr: |
180 |
| - case PlacementAndCallbackAndErr: { |
| 164 | + // The following switch statement is only concerned about placement, |
| 165 | + // updates, and deletions. To avoid needing to add a case for every |
| 166 | + // possible bitmap value, we remove the secondary effects from the |
| 167 | + // effect tag and switch on that value. |
| 168 | + let primaryEffectTag = effectfulFiber.effectTag & ~(Callback | Err); |
| 169 | + switch (primaryEffectTag) { |
| 170 | + case Placement: { |
181 | 171 | commitInsertion(effectfulFiber);
|
182 | 172 | // Clear the "placement" from effect tag so that we know that this is inserted, before
|
183 | 173 | // any life-cycles like componentDidMount gets called.
|
184 |
| - effectfulFiber.effectTag ^= Placement; |
| 174 | + effectfulFiber.effectTag &= ~Placement; |
185 | 175 | break;
|
186 | 176 | }
|
187 |
| - case PlacementAndUpdate: |
188 |
| - case PlacementAndUpdateAndCallback: |
189 |
| - case PlacementAndUpdateAndErr: |
190 |
| - case PlacementAndUpdateAndCallbackAndErr: { |
| 177 | + case PlacementAndUpdate: { |
191 | 178 | // Placement
|
192 | 179 | commitInsertion(effectfulFiber);
|
193 | 180 | // Clear the "placement" from effect tag so that we know that this is inserted, before
|
194 | 181 | // any life-cycles like componentDidMount gets called.
|
195 |
| - effectfulFiber.effectTag ^= Placement; |
| 182 | + effectfulFiber.effectTag &= ~Placement; |
196 | 183 |
|
197 | 184 | // Update
|
198 | 185 | const current = effectfulFiber.alternate;
|
199 | 186 | commitWork(current, effectfulFiber);
|
200 | 187 | break;
|
201 | 188 | }
|
202 |
| - case Update: |
203 |
| - case UpdateAndErr: |
204 |
| - case UpdateAndCallback: |
205 |
| - case UpdateAndCallbackAndErr: { |
| 189 | + case Update: { |
206 | 190 | const current = effectfulFiber.alternate;
|
207 | 191 | commitWork(current, effectfulFiber);
|
208 | 192 | break;
|
209 | 193 | }
|
210 |
| - case Deletion: |
211 |
| - case DeletionAndCallback: |
212 |
| - case DeletionAndErr: |
213 |
| - case DeletionAndCallbackAndErr: { |
| 194 | + case Deletion: { |
214 | 195 | commitDeletion(effectfulFiber);
|
215 | 196 | break;
|
216 | 197 | }
|
|
0 commit comments