Skip to content

Commit f7d53e5

Browse files
committed
fix(propTypes): Fix remaining propTypes warnings in React 15.3
1 parent 117f0a2 commit f7d53e5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/ReactGridLayout.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export default class ReactGridLayout extends React.Component {
111111

112112
// Children must not have duplicate keys.
113113
children: function (props, propName, _componentName) {
114-
PropTypes.node.apply(this, arguments);
115114
var children = props[propName];
116115

117116
// Check children keys for duplicates. Throw if found.

lib/ResponsiveReactGridLayout.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveL
77
import ReactGridLayout from './ReactGridLayout';
88

99
const noop = function(){};
10+
const type = (obj) => Object.prototype.toString.call(obj);
1011

1112
import type {Layout} from './utils';
1213
type State = {
@@ -37,9 +38,16 @@ export default class ResponsiveReactGridLayout extends React.Component {
3738

3839
// layouts is an object mapping breakpoints to layouts.
3940
// e.g. {lg: Layout, md: Layout, ...}
40-
layouts: function (props) {
41-
React.PropTypes.object.isRequired.apply(this, arguments);
42-
Object.keys(props.layouts).forEach((key) => validateLayout(props.layouts[key], 'layouts.' + key));
41+
layouts(props, propName) {
42+
if (type(props[propName]) !== '[object Object]') {
43+
throw new Error('Layout property must be an object. Received: ' + type(props[propName]));
44+
}
45+
Object.keys(props[propName]).forEach((key) => {
46+
if (!(key in props.breakpoints)) {
47+
throw new Error('Each key in layouts must align with a key in breakpoints.');
48+
}
49+
validateLayout(props.layouts[key], 'layouts.' + key);
50+
});
4351
},
4452

4553
// The width of this component.

0 commit comments

Comments
 (0)