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
Copy file name to clipboardExpand all lines: docs/Glossary.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ This is a glossary of common terms used in the React Router codebase and documen
11
11
*[LocationDescriptor](#locationdescriptor)
12
12
*[LocationKey](#locationkey)
13
13
*[LocationState](#locationstate)
14
+
*[Params](#params)
14
15
*[Path](#path)
15
16
*[Pathname](#pathname)
16
-
*[Params](#params)
17
17
*[Query](#query)
18
18
*[QueryString](#querystring)
19
19
*[RedirectFunction](#redirectfunction)
@@ -66,10 +66,10 @@ A *hash* is a string that represents the hash portion of the URL. It is synonymo
66
66
## LeaveHook
67
67
68
68
```js
69
-
type LeaveHook= () => any;
69
+
type LeaveHook= (prevState:RouterState) => any;
70
70
```
71
71
72
-
A *leave hook* is a user-defined function that is called when a route is about to be unmounted.
72
+
A *leave hook* is a user-defined function that is called when a route is about to be unmounted. It receives the previous [router state](#routerstate) as its first argument.
73
73
74
74
## Location
75
75
@@ -127,6 +127,14 @@ This type gets its name from the first argument to HTML5's [`pushState`][pushSta
The word *params* refers to an object of key/value pairs that were parsed out of the original URL's [pathname](#pathname). The values of this object are typically strings, unless there is more than one param with the same name in which case the value is an array.
137
+
130
138
## Path
131
139
132
140
```js
@@ -143,14 +151,6 @@ type Pathname = string;
143
151
144
152
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.
145
153
146
-
## QueryString
147
-
148
-
```js
149
-
type QueryString = string;
150
-
```
151
-
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.
153
-
154
154
## Query
155
155
156
156
```js
@@ -159,13 +159,13 @@ type Query = Object;
159
159
160
160
A*query* is the parsed version of a [query string](#querystring).
161
161
162
-
## Params
162
+
## QueryString
163
163
164
164
```js
165
-
type Params = Object;
165
+
type QueryString = string;
166
166
```
167
167
168
-
The word *params* refers to an object ofkey/value pairs that were parsed out ofthe original URL's [pathname](#pathname). The values of this object are typically strings, unless there is more than one param with the same name in which case the value is an array.
168
+
A*query string* is the portion ofthe 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`inweb browsers.
169
169
170
170
## RedirectFunction
171
171
@@ -204,6 +204,8 @@ The term *route component* refers to a [component](#component) that is directly
204
204
- `route` – The [route](#route) that declared this component
205
205
- `routeParams` – A subset of the [params](#params) that were specified in the route's [`path`](#routepattern)
206
206
207
+
Route components should generally be component classes rather than strings. This will avoid potential issues with passing the injected props above to DOM components.
Copy file name to clipboardExpand all lines: docs/guides/RouteConfiguration.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ URL | Components
106
106
107
107
### Decoupling the UI from the URL
108
108
109
-
It would be nice if we could remove the `/inbox` segment from the `/inbox/messages/:id` URL pattern, but still render `Message` nested inside the `App -> Inbox` UI. Absolute `path`s let us do exactly that.
109
+
It would be nice if we could remove the `/inbox` segment from the `/inbox/messages/:id` URL pattern, but still render `Message` nested inside the `App -> Inbox` UI. Pathless routes let us do exactly that.
110
110
111
111
```js
112
112
render((
@@ -125,7 +125,7 @@ render((
125
125
), document.body)
126
126
```
127
127
128
-
The ability to use absolute paths in deeply nested routes gives us complete control over what the URL looks like! We don't have to add more segments to the URL just to get nested UI.
128
+
The ability to use declare routes without paths gives us complete control over what the URL looks like! We don't have to add more segments to the URL just to get nested UI.
129
129
130
130
We can now render the following URLs:
131
131
@@ -136,8 +136,6 @@ URL | Components
136
136
`/inbox` | `App -> Inbox`
137
137
`/messages/:id` | `App -> Inbox -> Message`
138
138
139
-
**Note**: Absolute paths may not be used in route config that is [dynamically loaded](/docs/guides/DynamicRouting.md).
140
-
141
139
### Preserving URLs
142
140
143
141
Wait a minute ... we just changed a URL! [That's not cool](http://www.w3.org/Provider/Style/URI.html). Now everyone who had a link to `/inbox/messages/5` has a **broken link**. :(
@@ -184,7 +182,7 @@ Continuing with our example above, if a user clicked on a link to `/about` from
184
182
185
183
Since [routes](/docs/Glossary.md#route) are usually nested, it's useful to use a concise nested syntax like [JSX](https://facebook.github.io/jsx/) to describe their relationship to one another. However, you may also use an array of plain [route](/docs/Glossary.md#route) objects if you prefer to avoid using JSX.
186
184
187
-
The `<Redirect>` configuration helper is not available when using plain routes, so you have to set up the redirect using the `onEnter` hook.
185
+
The `<Redirect>` configuration helper is not available when using plain routes, so you have to set up the redirect using the `onEnter` hook.
188
186
189
187
The route config we've discussed up to this point could also be specified like this:
0 commit comments