Skip to content

Commit c1122e3

Browse files
Merge pull request #279 from suresh-gangumalla/router/rootAPI
Router/root API
2 parents d8935de + 2752e29 commit c1122e3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Router/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,25 @@ const registerListener = () => {
484484
}
485485
})
486486
}
487+
488+
/**
489+
* Navigate to root hash
490+
*/
491+
const root = () => {
492+
const rootHash = getRootHash()
493+
if (isString(rootHash)) {
494+
navigate(rootHash)
495+
} else if (isFunction(rootHash)) {
496+
rootHash().then(res => {
497+
if (isObject(res)) {
498+
navigate(res.path, res.params)
499+
} else {
500+
navigate(res)
501+
}
502+
})
503+
}
504+
}
505+
487506
// export API
488507
export default {
489508
startRouter,
@@ -512,6 +531,7 @@ export default {
512531
App: RoutedApp,
513532
// keep backwards compatible
514533
focusPage: restoreFocus,
534+
root: root,
515535
/**
516536
* Deprecated api methods
517537
*/

0 commit comments

Comments
 (0)