1
1
var React = require ( 'react' ) ;
2
+ var RouteHandlerMixin = require ( '../mixins/RouteHandler' ) ;
2
3
3
4
/**
4
5
* A <RouteHandler> component renders the active child route handler
@@ -8,49 +9,16 @@ var RouteHandler = React.createClass({
8
9
9
10
displayName : 'RouteHandler' ,
10
11
12
+ mixins : [ RouteHandlerMixin ] ,
13
+
11
14
getDefaultProps : function ( ) {
12
15
return {
13
16
ref : '__routeHandler__'
14
17
} ;
15
18
} ,
16
19
17
- contextTypes : {
18
- getRouteAtDepth : React . PropTypes . func . isRequired ,
19
- getRouteComponents : React . PropTypes . func . isRequired ,
20
- routeHandlers : React . PropTypes . array . isRequired
21
- } ,
22
-
23
- childContextTypes : {
24
- routeHandlers : React . PropTypes . array . isRequired
25
- } ,
26
-
27
- getChildContext : function ( ) {
28
- return {
29
- routeHandlers : this . context . routeHandlers . concat ( [ this ] )
30
- } ;
31
- } ,
32
-
33
- getRouteDepth : function ( ) {
34
- return this . context . routeHandlers . length - 1 ;
35
- } ,
36
-
37
- componentDidMount : function ( ) {
38
- this . _updateRouteComponent ( ) ;
39
- } ,
40
-
41
- componentDidUpdate : function ( ) {
42
- this . _updateRouteComponent ( ) ;
43
- } ,
44
-
45
- _updateRouteComponent : function ( ) {
46
- var depth = this . getRouteDepth ( ) ;
47
- var components = this . context . getRouteComponents ( ) ;
48
- components [ depth ] = this . refs [ this . props . ref ] ;
49
- } ,
50
-
51
20
render : function ( ) {
52
- var route = this . context . getRouteAtDepth ( this . getRouteDepth ( ) ) ;
53
- return route ? React . createElement ( route . handler , this . props ) : null ;
21
+ return this . getRouteHandler ( ) ;
54
22
}
55
23
56
24
} ) ;
0 commit comments