react-grid-system
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -55,22 +55,8 @@ 'use strict'; | ||
_this.getStyle = function () { | ||
return _this.props.style(_this.state.screenClass, _this.props.children.props); | ||
}; | ||
_this.render = function () { | ||
if (_this.props.render) { | ||
return _react2.default.createElement( | ||
_react2.default.Fragment, | ||
null, | ||
_this.props.render(_this.state.screenClass) | ||
); | ||
} | ||
if (!_this.warned) { | ||
console.warn('Please use the render prop of ScreenClassRender. Using style and children is deprecated and will be removed in the next major release.'); | ||
_this.warned = true; | ||
} | ||
if (_this.props.style) { | ||
return _react2.default.cloneElement(_this.props.children, { style: _this.getStyle() }); | ||
} | ||
return false; | ||
return _react2.default.createElement( | ||
_react2.default.Fragment, | ||
null, | ||
_this.props.render(_this.state.screenClass) | ||
); | ||
}; | ||
@@ -89,20 +75,7 @@ | ||
/** | ||
* Deprecated, will be removed in the next major release | ||
*/ | ||
children: _propTypes2.default.element, | ||
/** | ||
* Deprecated, will be removed in the next major release | ||
*/ | ||
style: _propTypes2.default.func, | ||
/** | ||
* The function which return value will be rendered. | ||
* Will be called with one argument: the screen class. | ||
*/ | ||
render: _propTypes2.default.func | ||
render: _propTypes2.default.func.isRequired | ||
}; | ||
ScreenClassRender.defaultProps = { | ||
children: null, | ||
style: null, | ||
render: null | ||
}; | ||
exports.default = ScreenClassRender; |
{ | ||
"name": "react-grid-system", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "A no CSS Bootstrap-like responsive grid system for React.", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
@@ -13,22 +13,8 @@ /* global window */ | ||
/** | ||
* Deprecated, will be removed in the next major release | ||
*/ | ||
children: PropTypes.element, | ||
/** | ||
* Deprecated, will be removed in the next major release | ||
*/ | ||
style: PropTypes.func, | ||
/** | ||
* The function which return value will be rendered. | ||
* Will be called with one argument: the screen class. | ||
*/ | ||
render: PropTypes.func, | ||
render: PropTypes.func.isRequired, | ||
}; | ||
static defaultProps = { | ||
children: null, | ||
style: null, | ||
render: null, | ||
} | ||
constructor(props) { | ||
@@ -56,19 +42,5 @@ super(props); | ||
getStyle = () => this.props.style(this.state.screenClass, this.props.children.props); | ||
warned: false; | ||
render = () => { | ||
if (this.props.render) { | ||
return <React.Fragment>{this.props.render(this.state.screenClass)}</React.Fragment>; | ||
} | ||
if (!this.warned) { | ||
console.warn('Please use the render prop of ScreenClassRender. Using style and children is deprecated and will be removed in the next major release.'); | ||
this.warned = true; | ||
} | ||
if (this.props.style) { | ||
return React.cloneElement(this.props.children, { style: this.getStyle() }); | ||
} | ||
return false; | ||
} | ||
render = () => ( | ||
<React.Fragment>{this.props.render(this.state.screenClass)}</React.Fragment> | ||
); | ||
} |
Example usage, rendering a font size based on the screen class: | ||
``` | ||
<ScreenClassRender render={(screenClass) => ( | ||
<ScreenClassRender render={screenClass => ( | ||
<p style={{ fontSize: ['lg', 'xl'].includes(screenClass) ? '2rem' : '1rem' }} > | ||
@@ -6,0 +6,0 @@ Screen class: {screenClass} |
70032
1588