Skip to content

Commit f576e34

Browse files
committed
fix: fix HiddenRouter
1 parent e971f40 commit f576e34

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/smooth/src/router/HiddenRouter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, {
66
useContext,
77
useMemo,
88
} from 'react'
9+
import { createPath } from 'history'
910
import { Router, withRouter } from 'react-router-dom'
1011
import HiddenHistoryContext from './HiddenHistoryContext'
1112

@@ -15,6 +16,10 @@ export function useHiddenRouter() {
1516
return useContext(HiddenRouterContext)
1617
}
1718

19+
function createURL(location) {
20+
return typeof location === 'string' ? location : createPath(location)
21+
}
22+
1823
function HiddenRouter({ history, children }) {
1924
const hiddenHistory = useContext(HiddenHistoryContext)
2025
const promises = useRef([])
@@ -60,6 +65,7 @@ function HiddenRouter({ history, children }) {
6065
goForward: noop,
6166
listen: () => noop,
6267
block: () => noop,
68+
createHref: path => createURL(path),
6369
}
6470
}, [hiddenHistory.location])
6571

0 commit comments

Comments
 (0)