File tree Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
3
- export default function withAltContext ( flux , Component ) {
4
- return React . createClass ( {
5
- childContextTypes : {
6
- flux : React . PropTypes . object
7
- } ,
3
+ export default function withAltContext ( flux ) {
4
+ return function ( Component ) {
5
+ return React . createClass ( {
6
+ childContextTypes : {
7
+ flux : React . PropTypes . object
8
+ } ,
8
9
9
- getChildContext ( ) {
10
- return { flux }
11
- } ,
10
+ getChildContext ( ) {
11
+ return { flux }
12
+ } ,
12
13
13
- render ( ) {
14
- return React . createElement ( Component , this . props )
15
- }
16
- } )
14
+ render ( ) {
15
+ return React . createElement ( Component , this . props )
16
+ }
17
+ } )
18
+ }
17
19
}
Original file line number Diff line number Diff line change @@ -119,7 +119,13 @@ export default {
119
119
'works with context' ( ) {
120
120
const flux = new Flux ( )
121
121
122
- const ContextComponent = withAltContext ( flux , AltContainer )
122
+ @withAltContext ( flux )
123
+ class ContextComponent extends React . Component {
124
+ render ( ) {
125
+ return < AltContainer />
126
+ }
127
+ }
128
+
123
129
const tree = TestUtils . renderIntoDocument ( < ContextComponent /> )
124
130
125
131
const contextComponent = TestUtils . findRenderedComponentWithType (
@@ -149,7 +155,7 @@ export default {
149
155
}
150
156
} )
151
157
152
- const WrappedComponent = withAltContext ( flux , TestComponent )
158
+ const WrappedComponent = withAltContext ( flux ) ( TestComponent )
153
159
154
160
const node = TestUtils . renderIntoDocument ( < WrappedComponent /> )
155
161
const span = TestUtils . findRenderedDOMComponentWithTag ( node , 'span' )
You can’t perform that action at this time.
0 commit comments