Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force render mismatches style between the server and client #126

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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