File tree Expand file tree Collapse file tree 1 file changed +23
-24
lines changed Expand file tree Collapse file tree 1 file changed +23
-24
lines changed Original file line number Diff line number Diff line change 11import React , { useEffect , useState } from 'react'
2- import { BrowserRouter , Route } from 'react-router-dom'
2+ import { Route } from 'react-router-dom'
33
44export function AsyncComponent ( props ) {
55 const [ Component , setComponent ] = useState ( null )
@@ -36,30 +36,29 @@ export function AsyncComponent(props) {
3636
3737export default function DynamicRoute ( props ) {
3838 return (
39- < BrowserRouter >
40- < Route
41- path = "/"
42- render = { ( { history } ) => {
43- // console.info('Dynamic Route: window.location.pathname = ' + window.location.pathname)
44- // console.info('Dynamic Route: location.pathname = ' + location.pathname)
45- const onError = e => {
46- if ( e . message . startsWith ( 'Cannot find module' ) && window . location . pathname !== '/404' ) {
47- history . push ( '/404' )
48- return
49- }
50- throw e
39+ < Route
40+ path = "/"
41+ render = { ( { history } ) => {
42+ const onError = e => {
43+ if (
44+ e . message . startsWith ( 'Cannot find module' ) &&
45+ window . location . pathname !== '/404'
46+ ) {
47+ history . push ( '/404' )
48+ return
5149 }
50+ throw e
51+ }
5252
53- return (
54- < AsyncComponent
55- component = { props . page ( window . location . pathname ) }
56- loading = { props . loading || 'Loading..' }
57- onError = { props . onError || onError }
58- otherProps = { props . props }
59- />
60- )
61- } }
62- />
63- </ BrowserRouter >
53+ return (
54+ < AsyncComponent
55+ component = { props . page ( window . location . pathname ) }
56+ loading = { props . loading || 'Loading..' }
57+ onError = { props . onError || onError }
58+ otherProps = { props . props }
59+ />
60+ )
61+ } }
62+ />
6463 )
6564}
You can’t perform that action at this time.
0 commit comments