diff --git a/index.d.ts b/index.d.ts index 8d3cb4c5..dd4e8025 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,8 +26,10 @@ export interface RouterOnChangeArgs { router: Router; url: string; previous?: string; + previousRoute?: preact.VNode, active: preact.VNode[]; current: preact.VNode; + currentRoute: preact.VNode; } export interface RouterProps extends RoutableProps { diff --git a/src/index.js b/src/index.js index 501061ec..4caf4702 100644 --- a/src/index.js +++ b/src/index.js @@ -229,15 +229,19 @@ class Router extends Component { let current = active[0] || null; let previous = this.previousUrl; + let previousRoute = this.previousRoute; if (url!==previous) { this.previousUrl = url; + this.previousRoute = current; if (typeof onChange==='function') { onChange({ router: this, url, previous, + previousRoute, active, - current + current, + currentRoute: current }); } }