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 11import React from 'react'
22
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+ } ,
89
9- getChildContext ( ) {
10- return { flux }
11- } ,
10+ getChildContext ( ) {
11+ return { flux }
12+ } ,
1213
13- render ( ) {
14- return React . createElement ( Component , this . props )
15- }
16- } )
14+ render ( ) {
15+ return React . createElement ( Component , this . props )
16+ }
17+ } )
18+ }
1719}
Original file line number Diff line number Diff line change @@ -119,7 +119,13 @@ export default {
119119 'works with context' ( ) {
120120 const flux = new Flux ( )
121121
122- const ContextComponent = withAltContext ( flux , AltContainer )
122+ @withAltContext ( flux )
123+ class ContextComponent extends React . Component {
124+ render ( ) {
125+ return < AltContainer />
126+ }
127+ }
128+
123129 const tree = TestUtils . renderIntoDocument ( < ContextComponent /> )
124130
125131 const contextComponent = TestUtils . findRenderedComponentWithType (
@@ -149,7 +155,7 @@ export default {
149155 }
150156 } )
151157
152- const WrappedComponent = withAltContext ( flux , TestComponent )
158+ const WrappedComponent = withAltContext ( flux ) ( TestComponent )
153159
154160 const node = TestUtils . renderIntoDocument ( < WrappedComponent /> )
155161 const span = TestUtils . findRenderedDOMComponentWithTag ( node , 'span' )
You can’t perform that action at this time.
0 commit comments