Skip to content

Commit 18877f5

Browse files
committed
addressed comments
1 parent e72a310 commit 18877f5

12 files changed

+86
-76
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ import {
137137
mergeLanes,
138138
getBumpedLaneForHydration,
139139
pickArbitraryLane,
140-
getTransitionsForLanes,
141140
} from './ReactFiberLane.new';
142141
import {
143142
ConcurrentMode,
@@ -227,6 +226,7 @@ import {
227226
markSkippedUpdateLanes,
228227
getWorkInProgressRoot,
229228
pushRenderLanes,
229+
getWorkInProgressTransitions,
230230
} from './ReactFiberWorkLoop.new';
231231
import {setWorkInProgressVersion} from './ReactMutableSource.new';
232232
import {
@@ -1337,10 +1337,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
13371337
}
13381338

13391339
if (enableTransitionTracing) {
1340-
workInProgress.memoizedState.transitions = getTransitionsForLanes(
1341-
root,
1342-
renderLanes,
1343-
);
1340+
workInProgress.memoizedState.transitions = getWorkInProgressTransitions();
13441341
}
13451342

13461343
// Caution: React DevTools currently depends on this property
@@ -3508,10 +3505,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
35083505
pushRootCachePool(root);
35093506
}
35103507
if (enableTransitionTracing) {
3511-
workInProgress.memoizedState.transitions = getTransitionsForLanes(
3512-
root,
3513-
renderLanes,
3514-
);
3508+
workInProgress.memoizedState.transitions = getWorkInProgressTransitions();
35153509
}
35163510
resetHydrationState();
35173511
break;

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ import {
137137
mergeLanes,
138138
getBumpedLaneForHydration,
139139
pickArbitraryLane,
140-
getTransitionsForLanes,
141140
} from './ReactFiberLane.old';
142141
import {
143142
ConcurrentMode,
@@ -227,6 +226,7 @@ import {
227226
markSkippedUpdateLanes,
228227
getWorkInProgressRoot,
229228
pushRenderLanes,
229+
getWorkInProgressTransitions,
230230
} from './ReactFiberWorkLoop.old';
231231
import {setWorkInProgressVersion} from './ReactMutableSource.old';
232232
import {
@@ -1337,10 +1337,7 @@ function updateHostRoot(current, workInProgress, renderLanes) {
13371337
}
13381338

13391339
if (enableTransitionTracing) {
1340-
workInProgress.memoizedState.transitions = getTransitionsForLanes(
1341-
root,
1342-
renderLanes,
1343-
);
1340+
workInProgress.memoizedState.transitions = getWorkInProgressTransitions();
13441341
}
13451342

13461343
// Caution: React DevTools currently depends on this property
@@ -3508,10 +3505,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
35083505
pushRootCachePool(root);
35093506
}
35103507
if (enableTransitionTracing) {
3511-
workInProgress.memoizedState.transitions = getTransitionsForLanes(
3512-
root,
3513-
renderLanes,
3514-
);
3508+
workInProgress.memoizedState.transitions = getWorkInProgressTransitions();
35153509
}
35163510
resetHydrationState();
35173511
break;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,24 +2219,28 @@ function commitMutationEffectsOnFiber(
22192219
case HostRoot: {
22202220
const state = finishedWork.memoizedState;
22212221
const transitions = state.transitions;
2222-
if (transitions != null) {
2222+
if (transitions !== null) {
22232223
transitions.forEach(transition => {
22242224
// TODO(luna) Do we want to log TransitionStart in the startTransition callback instead?
22252225
addCallbackToPendingTransitionCallbacks({
22262226
type: TransitionStart,
22272227
transitionName: transition.name,
22282228
startTime: transition.startTime,
2229+
markerName: null,
2230+
pendingBoundaries: null,
22292231
});
22302232

22312233
addCallbackToPendingTransitionCallbacks({
22322234
type: TransitionComplete,
22332235
transitionName: transition.name,
22342236
startTime: transition.startTime,
2237+
markerName: null,
2238+
pendingBoundaries: null,
22352239
});
22362240
});
22372241

22382242
clearTransitionsForLanes(root, lanes);
2239-
state.transitions.clear();
2243+
state.transitions = null;
22402244
}
22412245
}
22422246
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,24 +2219,28 @@ function commitMutationEffectsOnFiber(
22192219
case HostRoot: {
22202220
const state = finishedWork.memoizedState;
22212221
const transitions = state.transitions;
2222-
if (transitions != null) {
2222+
if (transitions !== null) {
22232223
transitions.forEach(transition => {
22242224
// TODO(luna) Do we want to log TransitionStart in the startTransition callback instead?
22252225
addCallbackToPendingTransitionCallbacks({
22262226
type: TransitionStart,
22272227
transitionName: transition.name,
22282228
startTime: transition.startTime,
2229+
markerName: null,
2230+
pendingBoundaries: null,
22292231
});
22302232

22312233
addCallbackToPendingTransitionCallbacks({
22322234
type: TransitionComplete,
22332235
transitionName: transition.name,
22342236
startTime: transition.startTime,
2237+
markerName: null,
2238+
pendingBoundaries: null,
22352239
});
22362240
});
22372241

22382242
clearTransitionsForLanes(root, lanes);
2239-
state.transitions.clear();
2243+
state.transitions = null;
22402244
}
22412245
}
22422246
}

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -810,17 +810,13 @@ export function addTransitionToLanesMap(
810810
if (enableTransitionTracing) {
811811
const transitionLanesMap = root.transitionLanes;
812812
const index = laneToIndex(lane);
813-
const transitions = transitionLanesMap[index];
814-
if (transitions !== null) {
815-
transitions.add(transition);
816-
} else {
817-
if (__DEV__) {
818-
console.error(
819-
'React Bug: transition lanes accessed out of bounds index: %s',
820-
index.toString(),
821-
);
822-
}
813+
let transitions = transitionLanesMap[index];
814+
if (transitions === null) {
815+
transitions = [];
823816
}
817+
transitions.push(transition);
818+
819+
transitionLanesMap[index] = transitions;
824820
}
825821
}
826822

@@ -832,27 +828,24 @@ export function getTransitionsForLanes(
832828
return null;
833829
}
834830

835-
const transitionsForLanes = new Set();
831+
const transitionsForLanes = [];
836832
while (lanes > 0) {
837833
const index = laneToIndex(lanes);
838834
const lane = 1 << index;
839835
const transitions = root.transitionLanes[index];
840836
if (transitions !== null) {
841837
transitions.forEach(transition => {
842-
transitionsForLanes.add(transition);
838+
transitionsForLanes.push(transition);
843839
});
844-
} else {
845-
if (__DEV__) {
846-
console.error(
847-
'React Bug: transition lanes accessed out of bounds index: %s',
848-
index.toString(),
849-
);
850-
}
851840
}
852841

853842
lanes &= ~lane;
854843
}
855844

845+
if (transitionsForLanes.length === 0) {
846+
return null;
847+
}
848+
856849
return transitionsForLanes;
857850
}
858851

@@ -867,7 +860,7 @@ export function clearTransitionsForLanes(root: FiberRoot, lanes: Lane | Lanes) {
867860

868861
const transitions = root.transitionLanes[index];
869862
if (transitions !== null) {
870-
transitions.clear();
863+
root.transitionLanes[index] = null;
871864
} else {
872865
if (__DEV__) {
873866
console.error(

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -810,17 +810,13 @@ export function addTransitionToLanesMap(
810810
if (enableTransitionTracing) {
811811
const transitionLanesMap = root.transitionLanes;
812812
const index = laneToIndex(lane);
813-
const transitions = transitionLanesMap[index];
814-
if (transitions !== null) {
815-
transitions.add(transition);
816-
} else {
817-
if (__DEV__) {
818-
console.error(
819-
'React Bug: transition lanes accessed out of bounds index: %s',
820-
index.toString(),
821-
);
822-
}
813+
let transitions = transitionLanesMap[index];
814+
if (transitions === null) {
815+
transitions = [];
823816
}
817+
transitions.push(transition);
818+
819+
transitionLanesMap[index] = transitions;
824820
}
825821
}
826822

@@ -832,27 +828,24 @@ export function getTransitionsForLanes(
832828
return null;
833829
}
834830

835-
const transitionsForLanes = new Set();
831+
const transitionsForLanes = [];
836832
while (lanes > 0) {
837833
const index = laneToIndex(lanes);
838834
const lane = 1 << index;
839835
const transitions = root.transitionLanes[index];
840836
if (transitions !== null) {
841837
transitions.forEach(transition => {
842-
transitionsForLanes.add(transition);
838+
transitionsForLanes.push(transition);
843839
});
844-
} else {
845-
if (__DEV__) {
846-
console.error(
847-
'React Bug: transition lanes accessed out of bounds index: %s',
848-
index.toString(),
849-
);
850-
}
851840
}
852841

853842
lanes &= ~lane;
854843
}
855844

845+
if (transitionsForLanes.length === 0) {
846+
return null;
847+
}
848+
856849
return transitionsForLanes;
857850
}
858851

@@ -867,7 +860,7 @@ export function clearTransitionsForLanes(root: FiberRoot, lanes: Lane | Lanes) {
867860

868861
const transitions = root.transitionLanes[index];
869862
if (transitions !== null) {
870-
transitions.clear();
863+
root.transitionLanes[index] = null;
871864
} else {
872865
if (__DEV__) {
873866
console.error(

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import {createCache, retainCache} from './ReactFiberCacheComponent.new';
3939

4040
export type RootState = {
4141
element: any,
42-
cache?: Cache | null,
43-
transitions?: Transitions | null,
42+
cache: Cache | null,
43+
transitions: Transitions | null,
4444
};
4545

4646
function FiberRootNode(
@@ -95,7 +95,7 @@ function FiberRootNode(
9595
this.transitionCallbacks = null;
9696
const transitionLanesMap = (this.transitionLanes = []);
9797
for (let i = 0; i < TotalLanes; i++) {
98-
transitionLanesMap.push(new Set());
98+
transitionLanesMap.push(null);
9999
}
100100
}
101101

@@ -180,11 +180,14 @@ export function createFiberRoot(
180180
const initialState: RootState = {
181181
element: null,
182182
cache: initialCache,
183+
transitions: null,
183184
};
184185
uninitializedFiber.memoizedState = initialState;
185186
} else {
186187
const initialState: RootState = {
187188
element: null,
189+
cache: null,
190+
transitions: null,
188191
};
189192
uninitializedFiber.memoizedState = initialState;
190193
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import {createCache, retainCache} from './ReactFiberCacheComponent.old';
3939

4040
export type RootState = {
4141
element: any,
42-
cache?: Cache | null,
43-
transitions?: Transitions | null,
42+
cache: Cache | null,
43+
transitions: Transitions | null,
4444
};
4545

4646
function FiberRootNode(
@@ -95,7 +95,7 @@ function FiberRootNode(
9595
this.transitionCallbacks = null;
9696
const transitionLanesMap = (this.transitionLanes = []);
9797
for (let i = 0; i < TotalLanes; i++) {
98-
transitionLanesMap.push(new Set());
98+
transitionLanesMap.push(null);
9999
}
100100
}
101101

@@ -180,11 +180,14 @@ export function createFiberRoot(
180180
const initialState: RootState = {
181181
element: null,
182182
cache: initialCache,
183+
transitions: null,
183184
};
184185
uninitializedFiber.memoizedState = initialState;
185186
} else {
186187
const initialState: RootState = {
187188
element: null,
189+
cache: null,
190+
transitions: null,
188191
};
189192
uninitializedFiber.memoizedState = initialState;
190193
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export type BatchConfigTransition = {
2323
_updatedFibers?: Set<Fiber>,
2424
};
2525

26-
export type Transitions = Set<Transition> | null;
26+
export type Transitions = Array<Transition> | null;
2727

2828
export type TransitionCallbackObject = {|
2929
type: TransitionCallback,
3030
transitionName: string,
3131
startTime: number,
32-
markerName?: string,
33-
pendingBoundaries?: Array<SuspenseInfo>,
32+
markerName: string | null,
33+
pendingBoundaries: Array<SuspenseInfo> | null,
3434
|};
3535

3636
export type TransitionCallback = 0 | 1;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export type BatchConfigTransition = {
2323
_updatedFibers?: Set<Fiber>,
2424
};
2525

26-
export type Transitions = Set<Transition> | null;
26+
export type Transitions = Array<Transition> | null;
2727

2828
export type TransitionCallbackObject = {|
2929
type: TransitionCallback,
3030
transitionName: string,
3131
startTime: number,
32-
markerName?: string,
33-
pendingBoundaries?: Array<SuspenseInfo>,
32+
markerName: string | null,
33+
pendingBoundaries: Array<SuspenseInfo> | null,
3434
|};
3535

3636
export type TransitionCallback = 0 | 1;

0 commit comments

Comments
 (0)