@@ -6,6 +6,15 @@ import { GutterWidthContext } from '../Row';
6
6
import ScreenClassResolver from '../../context/ScreenClassResolver' ;
7
7
8
8
export default class Col extends React . PureComponent {
9
+ constructor ( props ) {
10
+ super ( props ) ;
11
+ this . state = { hasMounted : false } ;
12
+ }
13
+
14
+ componentDidMount ( ) {
15
+ this . setState ( { hasMounted : true } ) ;
16
+ }
17
+
9
18
renderCol = ( gutterWidth , screenClass ) => {
10
19
const {
11
20
children,
@@ -22,23 +31,26 @@ export default class Col extends React.PureComponent {
22
31
component,
23
32
...otherProps
24
33
} = this . props ;
25
- const theStyle = getStyle ( {
26
- width : {
27
- xs,
28
- sm,
29
- md,
30
- lg,
31
- xl,
32
- } ,
33
- offset,
34
- pull,
35
- push,
36
- debug,
37
- screenClass,
38
- gutterWidth,
39
- gridColumns : getConfiguration ( ) . gridColumns ,
40
- moreStyle : style ,
41
- } ) ;
34
+ const { hasMounted } = this . state ;
35
+ const theStyle = hasMounted
36
+ ? getStyle ( {
37
+ width : {
38
+ xs,
39
+ sm,
40
+ md,
41
+ lg,
42
+ xl,
43
+ } ,
44
+ offset,
45
+ pull,
46
+ push,
47
+ debug,
48
+ screenClass,
49
+ gutterWidth,
50
+ gridColumns : getConfiguration ( ) . gridColumns ,
51
+ moreStyle : style ,
52
+ } )
53
+ : undefined ;
42
54
return createElement ( component , { style : theStyle , ...otherProps , children } ) ;
43
55
} ;
44
56
@@ -61,38 +73,23 @@ Col.propTypes = {
61
73
/**
62
74
* The width of the column for screenclass `xs`, either a number between 0 and 12, or "content"
63
75
*/
64
- xs : PropTypes . oneOfType ( [
65
- PropTypes . number ,
66
- PropTypes . oneOf ( [ 'content' ] ) ,
67
- ] ) ,
76
+ xs : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . oneOf ( [ 'content' ] ) ] ) ,
68
77
/**
69
78
* The width of the column for screenclass `sm`, either a number between 0 and 12, or "content"
70
79
*/
71
- sm : PropTypes . oneOfType ( [
72
- PropTypes . number ,
73
- PropTypes . oneOf ( [ 'content' ] ) ,
74
- ] ) ,
80
+ sm : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . oneOf ( [ 'content' ] ) ] ) ,
75
81
/**
76
82
* The width of the column for screenclass `md`, either a number between 0 and 12, or "content"
77
83
*/
78
- md : PropTypes . oneOfType ( [
79
- PropTypes . number ,
80
- PropTypes . oneOf ( [ 'content' ] ) ,
81
- ] ) ,
84
+ md : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . oneOf ( [ 'content' ] ) ] ) ,
82
85
/**
83
86
* The width of the column for screenclass `lg`, either a number between 0 and 12, or "content"
84
87
*/
85
- lg : PropTypes . oneOfType ( [
86
- PropTypes . number ,
87
- PropTypes . oneOf ( [ 'content' ] ) ,
88
- ] ) ,
88
+ lg : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . oneOf ( [ 'content' ] ) ] ) ,
89
89
/**
90
90
* The width of the column for screenclass `xl`, either a number between 0 and 12, or "content"
91
91
*/
92
- xl : PropTypes . oneOfType ( [
93
- PropTypes . number ,
94
- PropTypes . oneOf ( [ 'content' ] ) ,
95
- ] ) ,
92
+ xl : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . oneOf ( [ 'content' ] ) ] ) ,
96
93
/**
97
94
* The offset of this column for all screenclasses
98
95
*/
0 commit comments