-
Notifications
You must be signed in to change notification settings - Fork 109
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
Failed prop type: Invalid prop children
of type object
supplied to _class
, expected function
#101
Comments
you can wrap Measure in HOC: import React from 'react';
import Measure from 'react-measure';
const withMeasure = measurments => BaseComponent => props => (
<Measure {...[].concat(measurments).reduce((obj, m) => ({ ...obj, [m]: true }), {})}>
{({ contentRect, measure, measureRef }) => (
<BaseComponent {...props} {...{ contentRect, measure, measureRef }} />
)}
</Measure>
);
export default withMeasure; and use it after: withMeasure('bounds')(Component);
// or
withMeasure(['bounds', 'offset'])(Component); |
I'm getting this exact error message when invoking the withContentRect HOC. const addPropsToChildren = (children, props) =>
Children.map(children, child => cloneElement(child, props));
const Scrollbox = styled.div``;
const ScrollTracker = withContentRect("bounds")(
({ measureRef, height, children }) => (
<Scrollbox innerRef={measureRef}>
{addPropsToChildren(children, { height })}
</Scrollbox>
),
); As far as I can tell, I am using the HOC correctly, the onResize handler gets called and updates the state, height is correct and gets updated, everything seems to work - but I keep getting the proptype error. |
Looks like |
I refactored to use the component instead, and got rid of the error. |
I'm getting this warning in the console whenever I try to use this library. It works perfectly but it still spits out this warning.
This is a simplified version of how I'm using it:
The text was updated successfully, but these errors were encountered: