Skip to content

Commit fcd3cb9

Browse files
committed
render nothing depending on React version
1 parent 83e6c06 commit fcd3cb9

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/extendReactClass.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import _ from 'lodash';
44
import hoistNonReactStatics from 'hoist-non-react-statics';
55
import linkClass from './linkClass';
6+
import renderNothing from './renderNothing';
67

78
/**
89
* @param {ReactClass} Component
@@ -48,9 +49,9 @@ export default (Component: Object, defaultStyles: Object, options: Object) => {
4849
return linkClass(renderResult, styles, options);
4950
}
5051

51-
return null;
52+
return renderNothing();
5253
}
53-
};
54+
};
5455

5556
return hoistNonReactStatics(WrappedComponent, Component);
5657
};

src/renderNothing.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
3+
export default function () {
4+
const major = React.version.split('.')[0];
5+
6+
return parseInt(major, 10) < 15 ? React.createElement('noscript') : null;
7+
}

src/wrapStatelessFunction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import _ from 'lodash';
44
import linkClass from './linkClass';
5+
import renderNothing from './renderNothing';
56

67
/**
78
* @see https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components
@@ -38,7 +39,7 @@ export default (Component: Function, defaultStyles: Object, options: Object): Fu
3839
return linkClass(renderResult, styles, options);
3940
}
4041

41-
return null;
42+
return renderNothing();
4243
};
4344

4445
_.assign(WrappedComponent, Component);

0 commit comments

Comments
 (0)