1
- React Router
2
- ============
1
+ React Nested Router
2
+ ===================
3
3
4
- Declarative routing with automatic UI nesting for React.
4
+ A complete routing library for React.
5
5
6
6
Features
7
7
--------
@@ -20,19 +20,15 @@ and workflows are to create.
20
20
Installation
21
21
------------
22
22
23
- ` npm install rpflorence/react-router `
24
-
25
- We'll get on npm's registry soon.
26
-
27
- WIP
28
- ---
29
-
30
- This is a work in progress but the API seems to have settled.
23
+ ` npm install react-nested-router `
31
24
32
25
Usage
33
26
-----
34
27
35
- ``` js
28
+ This library only ships with common js modules, so you'll need browserify or
29
+ webpack or something that can load/bundle it.
30
+
31
+ ```
36
32
var Router = require('react-router');
37
33
var Route = Router.Route;
38
34
var Link = Router.Link;
@@ -47,12 +43,25 @@ Router(
47
43
).renderComponent(document.body);
48
44
```
49
45
46
+ Or if JSX isn't your jam:
47
+
48
+ ``` js
49
+ Router (
50
+ Route ({handler: App},
51
+ Route ({name: " about" , handler: About}),
52
+ Route ({name: " users" , handler: Users},
53
+ Route ({name= " user" , path: " user/:userId" , handler: User})
54
+ )
55
+ )
56
+ ).renderComponent (document .body );
57
+ ```
58
+
50
59
When a ` Route ` is active, you'll get an instance of ` handler `
51
60
automatically rendered for you. When one of the child routes is active,
52
- you can render it with ` this.props.activeRoute ` all the way down the
53
- view hierarchy. This allows you to create nested layouts without having
54
- to wire it all up yourself. ` Link ` components create accessible anchor
55
- tags to route you around the application.
61
+ you can render it with ` this.props.activeRoute ` in the parent all the
62
+ way down the view hierarchy. This allows you to create nested layouts
63
+ without having to wire it all up yourself. ` Link ` components create
64
+ accessible anchor tags to route you around the application.
56
65
57
66
Here's the rest of the application:
58
67
@@ -96,6 +105,31 @@ var User = React.createClass({
96
105
});
97
106
```
98
107
108
+ Benefits of This Approach
109
+ -------------------------
110
+
111
+ 1 . ** Incredible screen-creation productivity** - There is only one
112
+ use-case when a user visits a route: render something. Every user
113
+ interface has layers (or nesting) whether its a simple navbar or
114
+ multiple levels of master-detail. Coupling nested routes to these
115
+ nested views gets rid of a ton of work for the developer to wire all
116
+ of it together when the user switches routes. Adding new screens
117
+ could not get faster.
118
+
119
+ 2 . ** Immediate understanding of application structure** - When routes
120
+ are declared in one place, developers can easily construct a mental
121
+ image of the application. It's essentially a sitemap. There's not a
122
+ better way to get so much information about your app this quickly.
123
+
124
+ 3 . ** Code tractability** - When a developer gets a ticket to fix a bug
125
+ at as specific url they simply 1) look at the route config, then 2)
126
+ go find the handler for that route. Every entry point into your
127
+ application is represented by these routes.
128
+
129
+ 4 . ** URLs are your first thought, not an after-thought** - With React
130
+ Nested Router, you don't get UI on the page without configuring a url
131
+ first. Fortunately, its wildly productive this way, too.
132
+
99
133
API
100
134
---
101
135
@@ -285,36 +319,13 @@ active -->
285
319
<a href =" #/users/123" >Michael</a >
286
320
```
287
321
288
- Benefits of This Approach
289
- -------------------------
290
-
291
- 1 . ** Incredible screen-creation productivity** - There is only one
292
- use-case when a user visits a route: render something. Every user
293
- interface has layers (or nesting) whether its a simple navbar or
294
- multiple levels of master-detail. Coupling nested routes to these
295
- nested views gets rid of a ton of work for the developer to wire all
296
- of it together when the user switches routes. Adding new screens
297
- could not get faster.
298
-
299
- 2 . ** Immediate understanding of application structure** - When routes
300
- are declared in one place, developers can easily construct a mental
301
- image of the application. It's essentially a sitemap. There's not a
302
- better way to get so much information about your app this quickly.
303
-
304
- 3 . ** Code tractability** - When a developer gets a ticket to fix a bug
305
- at as specific url they simply 1) look at the route config, then 2)
306
- go find the handler for that route. Every entry point into your
307
- application is represented by these routes.
308
-
309
- 4 . ** URLs are your first thought, not an after-thought** - With
310
- React Router, you don't get UI on the page without configuring a url
311
- first. Fortunately, its wildly productive this way, too.
312
-
313
322
Development
314
323
-----------
315
324
316
- ` script/test ` will fire up a karma runner, ` npm test ` will do the same
317
- but with the ` --single-run ` option.
325
+ - ` script/test ` will fire up a karma runner and watch for changes in the
326
+ specs directory.
327
+ - ` npm test ` will do the same but doesn't watch, just runs the tests.
328
+ - ` script/build-examples ` does exactly that.
318
329
319
330
Thanks, Ember
320
331
-------------
0 commit comments