Skip to content

Commit ac8aaed

Browse files
authored
added history action (#1)
* added history action * historyAction * rename action to historyAction
1 parent 91e7000 commit ac8aaed

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/browser-router.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default class BrowserRouter extends Router {
6868
go(n) {
6969
this.history.go(n);
7070
}
71-
private _locationChanged = async ({ pathname, hash, search }) => {
71+
private _locationChanged = async ({ pathname, hash, search }, historyAction) => {
7272
const path = pathname + search + hash;
7373
let { location, route, status, params, redirect, result, ctx, error } = await this.router.run({ path });
7474
if (error !== null) {
@@ -86,7 +86,7 @@ export default class BrowserRouter extends Router {
8686
error
8787
}
8888
};
89-
const renderCallback = Router.makeCallback(this.router, { path, location, route, status, params, redirect, result, ctx });
89+
const renderCallback = Router.makeCallback(this.router, { path, location, route, status, params, redirect, result, historyAction, ctx });
9090
this.changeComponent({ Component: result, componentProps: props, path, location, error, renderCallback });
9191
};
9292
componentDidMount() {
@@ -95,6 +95,7 @@ export default class BrowserRouter extends Router {
9595
componentWillUnmount() {
9696
this.unlistenHistroy();
9797
}
98+
9899
render() {
99100
return (
100101
<div>

src/router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default class Router extends React.Component<Props, State> {
107107
errors
108108
},
109109
componentProps,
110-
callback: this.makeCallback(router, { path, location, route, status, params, redirect, result, ctx }),
110+
callback: this.makeCallback(router, { path, location, route, status, params, redirect, result, historyAction: null, ctx }),
111111
error
112112
}
113113
}

0 commit comments

Comments
 (0)