GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Transition Tracing] Fix excess calls to the transition start callbac… · react/react@d1432ba

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-reconciler/src
    • ReactFiberLane.new.js
    • ReactFiberLane.old.js
    • ReactInternalTypes.js
    • __tests__
      • ReactTransitionTracing-test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.new.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,9 @@ export function addTransitionToLanesMap(
846846
const index = laneToIndex(lane);
847847
let transitions = transitionLanesMap[index];
848848
if (transitions === null) {
849-
transitions = [];
849+
transitions = new Set();
850850
}
851-
transitions.push(transition);
851+
transitions.add(transition);
852852

853853
transitionLanesMap[index] = transitions;
854854
}
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberLane.old.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,9 @@ export function addTransitionToLanesMap(
813813
const index = laneToIndex(lane);
814814
let transitions = transitionLanesMap[index];
815815
if (transitions === null) {
816-
transitions = [];
816+
transitions = new Set();
817817
}
818-
transitions.push(transition);
818+
transitions.add(transition);
819819

820820
transitionLanesMap[index] = transitions;
821821
}
Collapse file

‎packages/react-reconciler/src/ReactInternalTypes.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactInternalTypes.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export type TransitionTracingCallbacks = {
328328
// The following fields are only used in transition tracing in Profile builds
329329
type TransitionTracingOnlyFiberRootProperties = {|
330330
transitionCallbacks: null | TransitionTracingCallbacks,
331-
transitionLanes: Array<Array<Transition> | null>,
331+
transitionLanes: Array<Set<Transition> | null>,
332332
// Transitions on the root can be represented as a bunch of tracing markers.
333333
// Each entangled group of transitions can be treated as a tracing marker.
334334
// It will have a set of pending suspense boundaries. These transitions
Collapse file

‎packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,69 @@ describe('ReactInteractionTracing', () => {
212212
});
213213
});
214214

215+
// @gate enableTransitionTracing
216+
it('multiple updates in transition callback should only result in one transitionStart/transitionComplete call', async () => {
217+
const transitionCallbacks = {
218+
onTransitionStart: (name, startTime) => {
219+
Scheduler.unstable_yieldValue(
220+
`onTransitionStart(${name}, ${startTime})`,
221+
);
222+
},
223+
onTransitionComplete: (name, startTime, endTime) => {
224+
Scheduler.unstable_yieldValue(
225+
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
226+
);
227+
},
228+
};
229+
230+
let navigateToPageTwo;
231+
let setText;
232+
function App() {
233+
const [navigate, setNavigate] = useState(false);
234+
const [text, _setText] = useState('hide');
235+
navigateToPageTwo = () => setNavigate(true);
236+
setText = () => _setText('show');
237+
238+
return (
239+
<div>
240+
{navigate ? (
241+
<Text text={`Page Two: ${text}`} />
242+
) : (
243+
<Text text={`Page One: ${text}`} />
244+
)}
245+
</div>
246+
);
247+
}
248+
249+
const root = ReactNoop.createRoot({transitionCallbacks});
250+
await act(async () => {
251+
root.render(<App />);
252+
ReactNoop.expire(1000);
253+
await advanceTimers(1000);
254+
255+
expect(Scheduler).toFlushAndYield(['Page One: hide']);
256+
257+
await act(async () => {
258+
startTransition(
259+
() => {
260+
navigateToPageTwo();
261+
setText();
262+
},
263+
{name: 'page transition'},
264+
);
265+
266+
ReactNoop.expire(1000);
267+
await advanceTimers(1000);
268+
269+
expect(Scheduler).toFlushAndYield([
270+
'Page Two: show',
271+
'onTransitionStart(page transition, 1000)',
272+
'onTransitionComplete(page transition, 1000, 2000)',
273+
]);
274+
});
275+
});
276+
});
277+
215278
// @gate enableTransitionTracing
216279
it('should correctly trace interactions for async roots', async () => {
217280
const transitionCallbacks = {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.