MCPcopy
hub / github.com/facebook/react / handler

Function handler

fixtures/view-transition/src/components/App.js:43–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 const newURL = new URL(event.destination.url);
42 event.intercept({
43 handler() {
44 let promise;
45 startTransition(() => {
46 addTransitionType('navigation-' + navigationType);
47 if (navigationType === 'traverse') {
48 // For traverse types it's useful to distinguish going back or forward.
49 const nextIndex = event.destination.index;
50 if (nextIndex > previousIndex) {
51 addTransitionType('navigation-forward');
52 } else if (nextIndex < previousIndex) {
53 addTransitionType('navigation-back');
54 }
55 }
56 promise = new Promise(resolve => {
57 setRouterState({
58 url: newURL.pathname + newURL.search,
59 pendingNav: resolve,
60 });
61 });
62 });
63 return promise;
64 },
65 commit: 'after-transition', // plz ship this, browsers
66 });
67 });

Callers

nothing calls this directly

Calls 2

startTransitionFunction · 0.90
addTransitionTypeFunction · 0.85

Tested by

no test coverage detected