Skip to content

Commit 54ec6a8

Browse files
committed
don’t create a hashHistory if there is no DOM
1 parent b9f8a38 commit 54ec6a8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

modules/hashHistory.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import useRouterHistory from './useRouterHistory'
22
import createHashHistory from 'history/lib/createHashHistory'
33

4-
export default useRouterHistory(createHashHistory)()
4+
const canUseDOM = !!(
5+
typeof window !== 'undefined' && window.document && window.document.createElement
6+
)
7+
8+
let history
9+
10+
if (canUseDOM) {
11+
history = useRouterHistory(createHashHistory)()
12+
}
13+
14+
export default history
515

0 commit comments

Comments
 (0)