Skip to content

Commit b9f5649

Browse files
committed
BrowserRoute 제거
1 parent 62f94d3 commit b9f5649

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

src/index.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react'
2-
import { BrowserRouter, Route } from 'react-router-dom'
2+
import { Route } from 'react-router-dom'
33

44
export function AsyncComponent(props) {
55
const [Component, setComponent] = useState(null)
@@ -36,30 +36,29 @@ export function AsyncComponent(props) {
3636

3737
export 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
}

0 commit comments

Comments
 (0)