Last active
April 9, 2018 07:49
-
-
Save dbismut/eac43782ed22c50932f2426f904c2629 to your computer and use it in GitHub Desktop.
Part 1 - Creating router5 router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createRouter from 'router5'; | |
import browserPlugin from 'router5/plugins/browser'; | |
import loggerPlugin from 'router5/plugins/logger'; | |
export default function configureRouter(routes, options = {}) { | |
const router = createRouter(routes, options) | |
// Plugins | |
.usePlugin(browserPlugin({ useHash: false })); | |
if (process.env.NODE_ENV === 'development') router.usePlugin(loggerPlugin); | |
// prevent automatic scroll restauration | |
if (window.history.scrollRestoration) | |
window.history.scrollRestoration = 'manual'; | |
return router; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment