Back Forward History
This is an addon to the JavaScript history library. It enables tracking of back and forward locations.
Setup
import React from 'react'
import { render } from 'react-dom'
import { Router, Route, browserHistory } from 'react-router'
import HistoryTracker from './back-forward-history'
HistoryTracker.listenTo(browserHistory)
API
listenTo(browserHistory)
Call this method to initialize this addon. Calling it more than once will result in unexpected behavior
canGoBack(n = 1)
Check if you can go back n pages. Defaults to 1.
canGoForward(n = 1)
Check if you can go forward n pages. Defaults to 1.
setTagForKey(key, tag)
Set a tag for a location you may want to return to. Get a key with
currentLocationKey
.
deleteTag(tag)
HistoryTracker.deleteTag('homepage')
goToLocationWithTag(tag)
Goes backward or forward to reach a tag.
Changes
1.1.5
- Fix deleteTag method name
1.1.4
- Forgot to recreate index.js in babel
1.1.3
- Ensure tags and titles are saved to sessionStorage in case of a reload
1.1.2
- Fix babel compiling
1.1.1
- Added deleteTag method
1.1
- Add pathname support