Add routing middleware

This commit is contained in:
Tom Raithel
2017-02-21 19:55:09 +01:00
parent 517df35b94
commit 61d46f96bb
2 changed files with 37 additions and 21 deletions

View File

@@ -1,23 +1,11 @@
import createHistory from 'history/createBrowserHistory';
export const NAVIGATE = 'navigate';
let history;
if (process.env.RENDER_MODE !== 'server') {
history = createHistory();
const unlisten = history.listen((location, action) => {
// location is an object like window.location
console.log(action, location.pathname, location.state)
});
}
const actions = {
navigate: (pageName) => {
history.push(`${pageName}.html`);
navigate: (pageName, pushToHistory = true) => {
return {
type: NAVIGATE,
pageName,
pushToHistory,
};
},
};