tmpl-cli
api
docs
env
git
hbs
html
husky
jest
lintstaged
lisp
node
prettier
python
react
readme
schema
style
util
Summaryutil asyncutil cookieutil dynamicutil event-listenerutil historyutil polyfillsutil react
vue
web

$ tmpl util history

Adds history util.

Files

project
└─src
└──utils
└───history.js

history.js

export const setPageInCurrentHistoryState = page => {
window.history.replaceState({ page }, page);
};
export const pushPageToBrowserHistory = page => {
window.history.pushState({ page }, page);
};
export const onHistoryPopGetPage = cb => {
window.onpopstate = event => {
cb(event.state);
};
};