Skip to content

Commit 19fbc0e

Browse files
committed
Force render mismatches style between the server and client
1 parent cce6b0d commit 19fbc0e

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

src/grid/Col/index.jsx

+34-37
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import { GutterWidthContext } from '../Row';
66
import ScreenClassResolver from '../../context/ScreenClassResolver';
77

88
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+
918
renderCol = (gutterWidth, screenClass) => {
1019
const {
1120
children,
@@ -22,23 +31,26 @@ export default class Col extends React.PureComponent {
2231
component,
2332
...otherProps
2433
} = 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;
4254
return createElement(component, { style: theStyle, ...otherProps, children });
4355
};
4456

@@ -61,38 +73,23 @@ Col.propTypes = {
6173
/**
6274
* The width of the column for screenclass `xs`, either a number between 0 and 12, or "content"
6375
*/
64-
xs: PropTypes.oneOfType([
65-
PropTypes.number,
66-
PropTypes.oneOf(['content']),
67-
]),
76+
xs: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
6877
/**
6978
* The width of the column for screenclass `sm`, either a number between 0 and 12, or "content"
7079
*/
71-
sm: PropTypes.oneOfType([
72-
PropTypes.number,
73-
PropTypes.oneOf(['content']),
74-
]),
80+
sm: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
7581
/**
7682
* The width of the column for screenclass `md`, either a number between 0 and 12, or "content"
7783
*/
78-
md: PropTypes.oneOfType([
79-
PropTypes.number,
80-
PropTypes.oneOf(['content']),
81-
]),
84+
md: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
8285
/**
8386
* The width of the column for screenclass `lg`, either a number between 0 and 12, or "content"
8487
*/
85-
lg: PropTypes.oneOfType([
86-
PropTypes.number,
87-
PropTypes.oneOf(['content']),
88-
]),
88+
lg: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
8989
/**
9090
* The width of the column for screenclass `xl`, either a number between 0 and 12, or "content"
9191
*/
92-
xl: PropTypes.oneOfType([
93-
PropTypes.number,
94-
PropTypes.oneOf(['content']),
95-
]),
92+
xl: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
9693
/**
9794
* The offset of this column for all screenclasses
9895
*/

0 commit comments

Comments
 (0)