File tree Expand file tree Collapse file tree 2 files changed +74
-4
lines changed Expand file tree Collapse file tree 2 files changed +74
-4
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,19 @@ Props
1010
1111### ` location `
1212
13- One of ` "hash" ` or ` "history" ` , defaults to ` "hash" ` .
13+ One of ` "hash" ` , ` "history" ` or a user defined location implementation,
14+ defaults to ` "hash" ` .
1415
15- Configures what type of url you want. ` "hash" ` includes ` #/ ` in the url and
16- works without a server, if you use ` history ` your server will need to
17- support it.
16+ ` "hash" ` includes ` #/ ` in the url and works without a server, if you use
17+ ` history ` your server will need to support it.
1818
1919For browsers that don't support the HTML5 history API the router will
2020fall back to ` window.location ` if you choose ` history ` , in other words,
2121the router will simply cause a full page reload. This way all users get
2222the same urls and can share them.
2323
24+ See also: [ user supplied locations] [ Location ] .
25+
2426### ` preserveScrollPosition `
2527
2628If ` true ` , the router will not scroll the window up globally when any
@@ -63,3 +65,5 @@ var routes = (
6365React .renderComponent (routes, document .body );
6466```
6567
68+ [ Location ] :../misc/Location.md
69+
Original file line number Diff line number Diff line change 1+ API: ` Location ` (object)
2+ ==========================
3+
4+ You can supply the router with your own location implementation. The
5+ following methods must be implemented:
6+
7+ Methods
8+ -------
9+
10+ ### ` setup(onChange) `
11+
12+ Called when the router is first setup. Whenever an external actor should
13+ cause the router to react, call ` onChange ` (for example, on
14+ ` window.hashchange ` ).
15+
16+ ### ` teardown `
17+
18+ Called when the router is torn down.
19+
20+ ### ` push `
21+
22+ Called when the router is transitioning from one path to another.
23+
24+ ### ` replace `
25+
26+ Called when ther router is replacing (not transitioning) one url with
27+ another.
28+
29+ ### ` pop `
30+
31+ Called when the router attempts to go back one entry in the history.
32+
33+ ### ` getCurrentPath `
34+
35+ Should return the current path as a string.
36+
37+ ### ` toString `
38+
39+ Should return a useful string for logging and debugging.
40+
41+ Example
42+ -------
43+
44+ This is a terrible example, you're probably better off looking at the
45+ implementations in this repository.
46+
47+ ``` js
48+ var MyLocation = {
49+
50+ setup : function (onChange ) {},
51+
52+ teardown : function () {},
53+
54+ push : function (path ) {},
55+
56+ replace : function (path ) {},
57+
58+ pop : function () {},
59+
60+ getCurrentPath : function () {},
61+
62+ toString : function () {}
63+
64+ };
65+ ```
66+
You can’t perform that action at this time.
0 commit comments