Skip to content

Commit

Permalink
fix(bug): Invalid propType validation within internals.
Browse files Browse the repository at this point in the history
Warnings were being thrown in console due to invalid propType validations on the RenderWrapper
component.  I've switched the size validators to be optional.  Thanks to @larrydahooster for the
tip!
  • Loading branch information
ctrlplusb committed Apr 15, 2016
1 parent 14890a8 commit 24672e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions example/src/MySizeAwareComponent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { PropTypes } from 'react';
import { merge } from 'lodash';

let SizeMe;

Expand All @@ -25,14 +24,15 @@ const spanStyle = {

function MyComponent({ size: { width, height }, style }) {
return (
<div style={merge({}, rootStyle, style)}>
<div style={Object.assign({}, rootStyle, style)}>
<span style={spanStyle}>
{Math.round(width)}x{Math.round(height)}<br />
<span style={{ fontWeight: `normal`, fontStyle: `italic` }}>(rounded)</span>
<span style={{ fontWeight: `normal`, fontStyle: `italic` }}>(rounded)</span>
</span>
</div>
);
}

MyComponent.propTypes = {
size: PropTypes.shape({
width: PropTypes.number.isRequired,
Expand All @@ -41,4 +41,4 @@ MyComponent.propTypes = {
style: PropTypes.object
};

export default SizeMe()(MyComponent);
export default SizeMe({ monitorHeight: true })(MyComponent);
4 changes: 2 additions & 2 deletions src/SizeMe.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ const RenderWrapper = (WrappedComponent) => {
className: PropTypes.string,
style: PropTypes.object,
size: PropTypes.shape({
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
width: PropTypes.number,
height: PropTypes.number,
})
};

Expand Down

0 comments on commit 24672e1

Please sign in to comment.