Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
BackForwardHistory/README.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (42 sloc)
1.2 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Back Forward History | |
This is an addon to the JavaScript | |
[history](https://github.com/mjackson/history) library. It enables tracking of | |
back and forward locations. | |
# Setup | |
```js | |
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) | |
```js | |
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 |