Skip to content

Commit

Permalink
Force render mismatches style between the server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
hdnha11 committed Dec 14, 2019
1 parent cce6b0d commit 19fbc0e
Showing 1 changed file with 34 additions and 37 deletions.
71 changes: 34 additions & 37 deletions src/grid/Col/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { GutterWidthContext } from '../Row';
import ScreenClassResolver from '../../context/ScreenClassResolver';

export default class Col extends React.PureComponent {
constructor(props) {
super(props);
this.state = { hasMounted: false };
}

componentDidMount() {
this.setState({ hasMounted: true });
}

renderCol = (gutterWidth, screenClass) => {
const {
children,
Expand All @@ -22,23 +31,26 @@ export default class Col extends React.PureComponent {
component,
...otherProps
} = this.props;
const theStyle = getStyle({
width: {
xs,
sm,
md,
lg,
xl,
},
offset,
pull,
push,
debug,
screenClass,
gutterWidth,
gridColumns: getConfiguration().gridColumns,
moreStyle: style,
});
const { hasMounted } = this.state;
const theStyle = hasMounted
? getStyle({
width: {
xs,
sm,
md,
lg,
xl,
},
offset,
pull,
push,
debug,
screenClass,
gutterWidth,
gridColumns: getConfiguration().gridColumns,
moreStyle: style,
})
: undefined;
return createElement(component, { style: theStyle, ...otherProps, children });
};

Expand All @@ -61,38 +73,23 @@ Col.propTypes = {
/**
* The width of the column for screenclass `xs`, either a number between 0 and 12, or "content"
*/
xs: PropTypes.oneOfType([
PropTypes.number,
PropTypes.oneOf(['content']),
]),
xs: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
/**
* The width of the column for screenclass `sm`, either a number between 0 and 12, or "content"
*/
sm: PropTypes.oneOfType([
PropTypes.number,
PropTypes.oneOf(['content']),
]),
sm: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
/**
* The width of the column for screenclass `md`, either a number between 0 and 12, or "content"
*/
md: PropTypes.oneOfType([
PropTypes.number,
PropTypes.oneOf(['content']),
]),
md: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
/**
* The width of the column for screenclass `lg`, either a number between 0 and 12, or "content"
*/
lg: PropTypes.oneOfType([
PropTypes.number,
PropTypes.oneOf(['content']),
]),
lg: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
/**
* The width of the column for screenclass `xl`, either a number between 0 and 12, or "content"
*/
xl: PropTypes.oneOfType([
PropTypes.number,
PropTypes.oneOf(['content']),
]),
xl: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['content'])]),
/**
* The offset of this column for all screenclasses
*/
Expand Down

0 comments on commit 19fbc0e

Please sign in to comment.