Skip to content

Commit 6fd05fe

Browse files
committed
Removed the render prop from the ContainerQuery component
1 parent c55e6b6 commit 6fd05fe

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Removed
11+
12+
- `react-container-query`
13+
- Removed the "render" prop in favour of using children. (The former was not
14+
even documented.)
15+
1016
## [3.0.0-alpha.1]
1117

1218
### Fixed

packages/react-container-query/.babelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
}
1818
]
1919
],
20-
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
20+
"plugins": [
21+
"@babel/plugin-proposal-object-rest-spread",
22+
"@babel/plugin-proposal-class-properties"
23+
]
2124
}

packages/react-container-query/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
},
2525
"devDependencies": {
2626
"@babel/core": "^7.1.6",
27+
"@babel/plugin-proposal-class-properties": "^7.2.1",
2728
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
2829
"@babel/preset-env": "^7.1.6",
2930
"@babel/preset-react": "^7.0.0",

packages/react-container-query/src/ContainerQuery.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,21 @@ export default class ContainerQuery extends Component {
99

1010
this.state = { size: null };
1111

12-
this.handleResize = this.handleResize.bind(this);
13-
1412
this.containerOptions = { ...this.props.options };
1513

1614
// Listen to size changes only if needed
17-
if (
18-
typeof this.props.render === "function" ||
19-
typeof this.props.children === "function"
20-
) {
15+
if (typeof this.props.children === "function") {
2116
this.containerOptions.handleResize = this.handleResize;
2217
}
2318
}
2419

25-
handleResize(size) {
26-
if (this.unMounting) {
20+
handleResize = size => {
21+
if (this.__willUnmount) {
2722
return;
2823
}
2924

3025
this.setState({ size });
31-
}
26+
};
3227

3328
componentDidMount() {
3429
if (!this.props.meta && !this.props.stats) {
@@ -55,7 +50,7 @@ export default class ContainerQuery extends Component {
5550
}
5651

5752
componentWillUnmount() {
58-
this.unMounting = true;
53+
this.__willUnmount = true;
5954
}
6055

6156
render() {
@@ -65,7 +60,7 @@ export default class ContainerQuery extends Component {
6560
return this.props.children;
6661
}
6762

68-
return this.props.render(this.state.size);
63+
return null;
6964
}
7065
}
7166

@@ -76,7 +71,6 @@ ContainerQuery.defaultProps = {
7671
};
7772

7873
ContainerQuery.propTypes = {
79-
render: PropTypes.func,
8074
stats: PropTypes.object,
8175
meta: PropTypes.object,
8276
options: PropTypes.object,

0 commit comments

Comments
 (0)