File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,21 @@ import React from 'react';
2
2
import classNames from 'classnames' ;
3
3
4
4
const Jumbotron = React . createClass ( {
5
+ propTypes : {
6
+ componentClass : React . PropTypes . any . isRequired
7
+ } ,
8
+
9
+ getDefaultProps ( ) {
10
+ return { componentClass : 'div' } ;
11
+ } ,
12
+
5
13
render ( ) {
14
+ const ComponentClass = this . props . componentClass ;
15
+
6
16
return (
7
- < div { ...this . props } className = { classNames ( this . props . className , 'jumbotron' ) } >
17
+ < ComponentClass { ...this . props } className = { classNames ( this . props . className , 'jumbotron' ) } >
8
18
{ this . props . children }
9
- </ div >
19
+ </ ComponentClass >
10
20
) ;
11
21
}
12
22
} ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ describe('Jumbotron', function () {
9
9
< strong > Content</ strong >
10
10
</ Jumbotron >
11
11
) ;
12
+
13
+ assert . equal ( React . findDOMNode ( instance ) . nodeName , 'DIV' ) ;
12
14
assert . ok ( ReactTestUtils . findRenderedDOMComponentWithTag ( instance , 'strong' ) ) ;
13
15
} ) ;
14
16
@@ -20,4 +22,13 @@ describe('Jumbotron', function () {
20
22
) ;
21
23
assert . ok ( React . findDOMNode ( instance ) . className . match ( / \b j u m b o t r o n \b / ) ) ;
22
24
} ) ;
25
+
26
+ it ( 'Should override node class' , function ( ) {
27
+ let instance = ReactTestUtils . renderIntoDocument (
28
+ < Jumbotron componentClass = 'section' >
29
+ < strong > Content</ strong >
30
+ </ Jumbotron >
31
+ ) ;
32
+ assert . equal ( React . findDOMNode ( instance ) . nodeName , 'SECTION' ) ;
33
+ } ) ;
23
34
} ) ;
You can’t perform that action at this time.
0 commit comments