Skip to content

Commit 2a7eb39

Browse files
committed
Destructure future prop
1 parent 9e675c7 commit 2a7eb39

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packages/react-router-dom/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,14 @@ export function BrowserRouter({
322322
action: history.action,
323323
location: history.location,
324324
});
325+
let { v7_startTransition } = future || {};
325326
let setState = React.useCallback(
326327
(newState: { action: NavigationType; location: Location }) => {
327-
future && future.v7_startTransition && startTransitionImpl
328+
v7_startTransition && startTransitionImpl
328329
? startTransitionImpl(() => setStateImpl(newState))
329330
: setStateImpl(newState);
330331
},
331-
[setStateImpl, future]
332+
[setStateImpl, v7_startTransition]
332333
);
333334

334335
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
@@ -371,13 +372,14 @@ export function HashRouter({
371372
action: history.action,
372373
location: history.location,
373374
});
375+
let { v7_startTransition } = future || {};
374376
let setState = React.useCallback(
375377
(newState: { action: NavigationType; location: Location }) => {
376-
future && future.v7_startTransition && startTransitionImpl
378+
v7_startTransition && startTransitionImpl
377379
? startTransitionImpl(() => setStateImpl(newState))
378380
: setStateImpl(newState);
379381
},
380-
[setStateImpl, future]
382+
[setStateImpl, v7_startTransition]
381383
);
382384

383385
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
@@ -416,13 +418,14 @@ function HistoryRouter({
416418
action: history.action,
417419
location: history.location,
418420
});
421+
let { v7_startTransition } = future || {};
419422
let setState = React.useCallback(
420423
(newState: { action: NavigationType; location: Location }) => {
421-
future && future.v7_startTransition && startTransitionImpl
424+
v7_startTransition && startTransitionImpl
422425
? startTransitionImpl(() => setStateImpl(newState))
423426
: setStateImpl(newState);
424427
},
425-
[setStateImpl, future]
428+
[setStateImpl, v7_startTransition]
426429
);
427430

428431
React.useLayoutEffect(() => history.listen(setState), [history, setState]);

packages/react-router/lib/components.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ export function RouterProvider({
7171
// Need to use a layout effect here so we are subscribed early enough to
7272
// pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
7373
let [state, setStateImpl] = React.useState(router.state);
74+
let { v7_startTransition } = future || {};
7475
let setState = React.useCallback(
7576
(newState: RouterState) => {
76-
future && future.v7_startTransition && startTransitionImpl
77+
v7_startTransition && startTransitionImpl
7778
? startTransitionImpl(() => setStateImpl(newState))
7879
: setStateImpl(newState);
7980
},
80-
[setStateImpl, future]
81+
[setStateImpl, v7_startTransition]
8182
);
8283
React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
8384

@@ -185,13 +186,14 @@ export function MemoryRouter({
185186
action: history.action,
186187
location: history.location,
187188
});
189+
let { v7_startTransition } = future || {};
188190
let setState = React.useCallback(
189191
(newState: { action: NavigationType; location: Location }) => {
190-
future && future.v7_startTransition && startTransitionImpl
192+
v7_startTransition && startTransitionImpl
191193
? startTransitionImpl(() => setStateImpl(newState))
192194
: setStateImpl(newState);
193195
},
194-
[setStateImpl, future]
196+
[setStateImpl, v7_startTransition]
195197
);
196198

197199
React.useLayoutEffect(() => history.listen(setState), [history, setState]);

0 commit comments

Comments
 (0)