@@ -300,6 +300,11 @@ export interface BrowserRouterProps {
300
300
window ?: Window ;
301
301
}
302
302
303
+ // Webpack + React 17 fails to compile on the usage of `React.startTransition` or
304
+ // `React["startTransition"]` even if it's behind a feature detection of
305
+ // `"startTransition" in React`. Moving this to a constant avoids the issue :/
306
+ const START_TRANSITION = "startTransition" ;
307
+
303
308
/**
304
309
* A `<Router>` for use in web browsers. Provides the cleanest URLs.
305
310
*/
@@ -320,8 +325,8 @@ export function BrowserRouter({
320
325
} ) ;
321
326
let setState = React . useCallback (
322
327
( newState : { action : NavigationType ; location : Location } ) => {
323
- "startTransition" in React
324
- ? React . startTransition ( ( ) => setStateImpl ( newState ) )
328
+ START_TRANSITION in React
329
+ ? React [ START_TRANSITION ] ( ( ) => setStateImpl ( newState ) )
325
330
: setStateImpl ( newState ) ;
326
331
} ,
327
332
[ setStateImpl ]
@@ -363,8 +368,8 @@ export function HashRouter({ basename, children, window }: HashRouterProps) {
363
368
} ) ;
364
369
let setState = React . useCallback (
365
370
( newState : { action : NavigationType ; location : Location } ) => {
366
- "startTransition" in React
367
- ? React . startTransition ( ( ) => setStateImpl ( newState ) )
371
+ START_TRANSITION in React
372
+ ? React [ START_TRANSITION ] ( ( ) => setStateImpl ( newState ) )
368
373
: setStateImpl ( newState ) ;
369
374
} ,
370
375
[ setStateImpl ]
@@ -402,8 +407,8 @@ function HistoryRouter({ basename, children, history }: HistoryRouterProps) {
402
407
} ) ;
403
408
let setState = React . useCallback (
404
409
( newState : { action : NavigationType ; location : Location } ) => {
405
- "startTransition" in React
406
- ? React . startTransition ( ( ) => setStateImpl ( newState ) )
410
+ START_TRANSITION in React
411
+ ? React [ START_TRANSITION ] ( ( ) => setStateImpl ( newState ) )
407
412
: setStateImpl ( newState ) ;
408
413
} ,
409
414
[ setStateImpl ]
0 commit comments