@@ -66,32 +66,38 @@ Usage
6666var Route = require('react-router').Route;
6767
6868React.renderComponent((
69- <Route handler={App}>
70- <Route name="about" handler={About}/>
71- <Route name="users" handler={Users}>
72- <Route name="user" path="/user/:userId" handler={User}/>
69+ <Routes>
70+ <Route handler={App}>
71+ <Route name="about" handler={About}/>
72+ <Route name="users" handler={Users}>
73+ <Route name="user" path="/user/:userId" handler={User}/>
74+ </Route>
7375 </Route>
74- </Route >
76+ </Routes >
7577), document.body);
7678```
7779
7880Or if JSX isn't your jam:
7981
8082``` js
8183React .renderComponent ((
82- Route ({handler: App},
83- Route ({name: " about" , handler: About}),
84- Route ({name: " users" , handler: Users},
85- Route ({name: " user" , path: " /user/:userId" , handler: User})
84+ Routes ({},
85+ Route ({handler: App},
86+ Route ({name: " about" , handler: About}),
87+ Route ({name: " users" , handler: Users},
88+ Route ({name: " user" , path: " /user/:userId" , handler: User})
89+ )
8690 )
8791 )
8892), document .body );
8993```
9094
91- - Urls will be matched to the deepest route, and then all the routes up
95+ - URLs will be matched to the deepest route, and then all the routes up
9296the hierarchy are activated and their "handlers" (normal React
9397components) will be rendered.
9498
99+ - Paths are assumed from names unless specified.
100+
95101- Each handler will receive a ` params ` property containing the matched
96102parameters form the url, like ` :userId ` .
97103
@@ -194,24 +200,33 @@ Related Modules
194200API
195201---
196202
203+ ### Routes (component)
204+
205+ Configuration component for your router, all ` <Route/> ` s must be
206+ children of a ` <Routes/> ` . It is the component you provide to
207+ ` React.renderComponent(routes, el) ` .
208+
209+ #### Props
210+
211+ ** location** - ` "hash" ` or ` "history" ` , defaults to ` "hash" ` . Configures
212+ what type of url you want, hash includes ` #/ ` in the url and works
213+ without a server, if you use ` history ` your server will need to support
214+ it.
215+
197216### Route (component)
198217
199218Configuration component to declare your application's routes and view hierarchy.
200219
201220#### Props
202221
203- ** location** - The method to use for page navigation when initializing the router.
204- May be either "hash" to use URLs with hashes in them and the ` hashchange ` event or
205- "history" to use the HTML5 history API. This prop is only ever used on the root
206- route that is rendered into the page. The default is "hash".
207-
208222** name** - The name of the route, used in the ` Link ` component and the
209223router's transition methods.
210224
211225** path** - The path used in the URL, supporting dynamic segments. If
212- left undefined, the path will be defined by the ` name ` . This path is always
213- absolute from the URL "root", even if the leading slash is left off. Nested
214- routes do not inherit the path of their parent.
226+ left undefined, the path will be defined by the ` name ` , and if there is
227+ no name, will default to ` / ` . This path is always absolute from the URL
228+ "root", even if the leading slash is left off. Nested routes do not
229+ inherit the path of their parent.
215230
216231** handler** - The component to be rendered when the route matches.
217232
@@ -225,14 +240,17 @@ passing in any additional props as needed.
225240#### Examples
226241
227242``` xml
228- <Route handler ={App}>
229- <!-- path is automatically assigned to the name since it is omitted -->
230- <Route name =" about" handler ={About}/>
231- <Route name =" users" handler ={Users}>
232- <!-- note the dynamic segment in the path -->
233- <Route name =" user" handler ={User} path =" /user/:id" />
243+ <Routes >
244+ <!-- path defaults to '/' since no name or path provided -->
245+ <Route handler ={App}>
246+ <!-- path is automatically assigned to the name since it is omitted -->
247+ <Route name =" about" handler ={About}/>
248+ <Route name =" users" handler ={Users}>
249+ <!-- note the dynamic segment in the path -->
250+ <Route name =" user" handler ={User} path =" /user/:id" />
251+ </Route >
234252 </Route >
235- </Route >
253+ </Routes >
236254```
237255
238256Or w/o JSX:
0 commit comments