You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns `true` or `false` depending on if the `pathnameOrLoc` is active. Will be true for every route in the route branch matched (child route is active, therefore parent is too), unless `onlyActiveOnIndex` is specified, in which case it will only match the exact path.
190
190
191
191
@@ -310,7 +310,7 @@ code-splitting.
310
310
##### `children`
311
311
Routes can be nested, `this.props.children` will contain the element created from the child route component. Please refer to the [Route Configuration](/docs/guides/basics/RouteConfiguration.md) since this is a very critical part of the router's design.
Called when a route is about to be entered. It provides the next router state and a function to redirect to another path. `this` will be the route instance that triggered the hook.
315
315
316
316
If `callback` is listed as a 3rd argument, this hook will run asynchronously, and the transition will block until `callback` is called.
Copy file name to clipboardExpand all lines: docs/Glossary.md
+36-26Lines changed: 36 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,10 @@ This is a glossary of common terms used in the React Router codebase and documen
5
5
*[Action](#action)
6
6
*[Component](#component)
7
7
*[EnterHook](#enterhook)
8
+
*[Hash](#hash)
8
9
*[LeaveHook](#leavehook)
9
10
*[Location](#location)
11
+
*[LocationDescriptor](#locationdescriptor)
10
12
*[LocationKey](#locationkey)
11
13
*[LocationState](#locationstate)
12
14
*[Path](#path)
@@ -21,7 +23,6 @@ This is a glossary of common terms used in the React Router codebase and documen
21
23
*[RouteHook](#routehook)
22
24
*[RoutePattern](#routepattern)
23
25
*[Router](#router)
24
-
*[RouterListener](#routerlistener)
25
26
*[RouterState](#routerstate)
26
27
27
28
## Action
@@ -47,15 +48,21 @@ A *component* is a React component class or a string (e.g. "div"). Basically, it
47
48
## EnterHook
48
49
49
50
```js
50
-
type EnterHook= (nextState:RouterState, replaceState:RedirectFunction, callback?:Function) => any;
51
+
type EnterHook= (nextState:RouterState, replace:RedirectFunction, callback?:Function) => any;
51
52
```
52
53
53
-
An *enter hook* is a user-defined function that is called when a route is about to be rendered. It receives the next [router state](#routerstate) as its first argument. The [`replaceState` function](#redirectfunction) may be used to trigger a transition to a different URL.
54
+
An *enter hook* is a user-defined function that is called when a route is about to be rendered. It receives the next [router state](#routerstate) as its first argument. The [`replace` function](#redirectfunction) may be used to trigger a transition to a different URL.
54
55
55
56
If an enter hook needs to execute asynchronously, it may list a 3rd `callback` argument that it must call in order to cause the transition to proceed.
56
57
57
58
**Caution:** Using the `callback` in an enter hook causes the transition to wait until it is called. **This can lead to a non-responsive UI if you don't call it very quickly**.
58
59
60
+
### Hash
61
+
62
+
type Hash = string;
63
+
64
+
A *hash* is a string that represents the hash portion of the URL. It is synonymous with `window.location.hash` in web browsers.
65
+
59
66
## LeaveHook
60
67
61
68
```js
@@ -84,6 +91,21 @@ A *location* answers two important (philosophical) questions:
84
91
85
92
New locations are typically created each time the URL changes. You can read more about locations in [the `history` docs](https://github.com/rackt/history/blob/master/docs/Location.md).
86
93
94
+
### LocationDescriptor
95
+
96
+
type LocationDescriptorObject = {
97
+
pathname: Pathname;
98
+
search: Search;
99
+
query: Query;
100
+
state: LocationState;
101
+
};
102
+
103
+
type LocationDescriptor = LocationDescriptorObject | Path;
104
+
105
+
A *location descriptor* is the pushable analogue of a location. Locations tell you where you are; you create location descriptors to say where to go.
106
+
107
+
You can read more about location descriptors in [the `history` docs](https://github.com/rackt/history/blob/master/docs/Location.md).
108
+
87
109
## LocationKey
88
110
89
111
```js
@@ -108,7 +130,7 @@ This type gets its name from the first argument to HTML5's [`pushState`][pushSta
108
130
## Path
109
131
110
132
```js
111
-
type Path = Pathname + QueryString;
133
+
type Path = Pathname + QueryString+ Hash;
112
134
```
113
135
114
136
A *path* represents a URL path.
@@ -119,15 +141,15 @@ A *path* represents a URL path.
119
141
type Pathname = string;
120
142
```
121
143
122
-
A *pathname* is the portion of a URL that describes a hierarchical path, including the preceeding`/`. For example, in `http://example.com/the/path?the=query`, `/the/path` is the pathname. It is synonymous with `window.location.pathname` in web browsers.
144
+
A *pathname* is the portion of a URL that describes a hierarchical path, including the preceding`/`. For example, in `http://example.com/the/path?the=query`, `/the/path` is the pathname. It is synonymous with `window.location.pathname` in web browsers.
123
145
124
146
## QueryString
125
147
126
148
```js
127
149
type QueryString = string;
128
150
```
129
151
130
-
A*query string* is the portion of the URL that follows the [pathname](#pathname), including any preceeding`?`. For example, in`http://example.com/the/path?the=query`, `?the=query` is the query string. It is synonymous with`window.location.search`in web browsers.
152
+
A*query string* is the portion of the URL that follows the [pathname](#pathname), including any preceding`?`. For example, in`http://example.com/the/path?the=query`, `?the=query` is the query string. It is synonymous with`window.location.search`in web browsers.
131
153
132
154
## Query
133
155
@@ -216,29 +238,17 @@ Route patterns are relative to the pattern of the parent route unless they begin
A *router* is a [`history`](http://rackt.github.io/history) object (akin to `window.history` in web browsers) that is used to modify and listen for changes to the URL.
229
-
230
-
There are two primary interfaces for computing a router's next [state](#routerstate):
231
-
232
-
-`history.listen` is to be used in stateful environments (such as web browsers) that need to update the UI over a period oftime. This method immediately invokes its `listener` argument once and returns a function that must be called to stop listening for changes
233
-
- `history.match` is a function that does not update the history's internal state. This makes it ideal for server-side environments where many requests must be handled concurrently
234
-
235
-
## RouterListener
236
-
237
-
```js
238
-
type RouterListener = (error:?Error, nextState:RouterState) => void;
239
-
```
240
-
241
-
A *router listener* is a function that is used to listen for changes to a [router](#router)'s [state](#routerstate).
251
+
A *router* object allows for procedural manipulation of the routing state.
0 commit comments