Migrating from 7.x to 8.x
router5 is three and a half years old, and a few things have changed since the start! This year (2018), we went from 2,000 downloads a week to 10,000 downloads a week, so thank you! It gave me the motivation to perform a complete refactor with a necessary modernisation of all packages, something I had procrastinated over for a while. I'm always happy to know more about users of router5, so come and say I: who is using router5?.
With version 7, all packages have been rewritten in TypeScript, and tooling is now consistent across packages. A few breaking changes have been introduced.
No longer maintained packages
An unmaintained directory has been created to move packages which are no longer maintained. deku-router5 has been added to it: if you are interested in maintaining it, I'm happy to consider transferring ownership.
Changes per package
router5
Features
Plugins now accept a
teardownmethod (alongsideonStart,onStop,onTransitionSuccess, etc.): it will be called when a plugin is removed.
BREAKING CHANGES
Plugins previously included with the router5 package (browser plugin, logger plugin, listeners plugin and persistent params plugin) have been moved to their own packages:
router5-plugin-browserrouter5-plugin-loggerrouter5-plugin-listenersrouter5-plugin-persistent-params
useMiddlewareno longer returns your router instance, but a function to remove the added middleware. You can still pass multiple middleware, in which case calling the teardown function will remove all of them.usePluginno longer returns your router instance, but a function to remove the added plugin. You can still pass multiple plugins, in which case calling the teardown function will remove all of them.hasPluginmethod has been removed, andpluginNameis no longer neededCloning is now done using a
cloneRouterfunction, and it no longer re-uses existing dependenciesimport { cloneRouter } from 'router5' const clonedRouter = cloneRouter(router, dependencies)When
reloadnavigate option is set totrue,fromStateis no longer set tonull:transitionPathhas been updated to take into account this change, if you have middleware or plugins with custom logic, make sure you update them.
react-router5
Features
Hooks have been added:
useRoute,useRouteNodeanduseRouter
BREAKING CHANGES
Linkhas been renamed toConnectedLink, andBaseLinkhas been renamed toLinkRouteProviderhas been renamed toRouterProvider: there is now only one providerreact-router5now requires React version 16.3.0 or above: it no longer uses the old context API. The migration path is quite easy:If you are not using React 16.3.0 (or above), and cannot upgrade to it, a new package
react-router5-hocshas been added: it is a drop-in replacement forreact-router5(Link component names stil need changed, see point above)If you are using React 16.3.0 and above, you are good to continue using
react-router5(see breaking changes above)
redux-router5
BREAKING CHANGES
For use with immutable.js, import
router5Reducerfromredux-router5-immutable
router5-helpers
BREAKING CHANGES
Undocumented
redirecthelper has been removed: it's no longer needed withforwardTo.
Last updated