File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * This component is necessary to get around a context warning
3
+ * present in React 0.13.0. It sovles this by providing a separation
4
+ * between the "owner" and "parent" contexts.
5
+ */
6
+
7
+ var React = require ( 'react' ) ;
8
+ var PropTypes = require ( '../PropTypes' ) ;
9
+
10
+ class ContextWrapper extends React . Component {
11
+
12
+ getChildContext ( ) {
13
+ return {
14
+ router : this . context . router ,
15
+ routeDepth : this . context . routeDepth
16
+ } ;
17
+ }
18
+
19
+ render ( ) {
20
+ return this . props . children ;
21
+ }
22
+ }
23
+
24
+ ContextWrapper . contextTypes = {
25
+ routeDepth : PropTypes . number . isRequired ,
26
+ router : PropTypes . router . isRequired
27
+ } ;
28
+
29
+ ContextWrapper . childContextTypes = {
30
+ routeDepth : PropTypes . number . isRequired ,
31
+ router : PropTypes . router . isRequired
32
+ } ;
33
+
34
+ module . exports = ContextWrapper ;
Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
+ var ContextWrapper = require ( './ContextWrapper' )
2
3
var assign = require ( 'react/lib/Object.assign' ) ;
3
4
var PropTypes = require ( '../PropTypes' ) ;
4
5
@@ -42,10 +43,7 @@ class RouteHandler extends React.Component {
42
43
}
43
44
44
45
render ( ) {
45
- // IMPORTANT: This span "soaks" up owner context, keeping
46
- // React 0.13.0 from throwing a warning.
47
- // TODO: Why should this even be necessary?
48
- return < span > { this . createChildRouteHandler ( ) } </ span >
46
+ return < ContextWrapper > { this . createChildRouteHandler ( ) } </ ContextWrapper >
49
47
}
50
48
51
49
}
You can’t perform that action at this time.
0 commit comments