-
Notifications
You must be signed in to change notification settings - Fork 78
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
Do not render "0" when parent height and width are both 0. #61
base: master
Are you sure you want to change the base?
Conversation
index.jsx
Outdated
@@ -168,13 +168,14 @@ module.exports = function Dimensions ({ | |||
} | |||
return ( | |||
<div style={wrapperStyle} ref='wrapper'> | |||
{(containerWidth || containerHeight) && | |||
<ComposedComponent | |||
{(containerWidth || containerHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way you are not creating the ComposedComponent if the dimensions are 0. This may lead to some confusion.
You could solve the printing of '0' by casting the above statement to a boolean like this !!(containerWidth || containerHeight)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComposedComponent
is already not being created. {(0 || 0) && <ComposedComponent>}
becomes {0}
which will render "0" as text. {(0 || 0) ? <ComposedComponent> : null}
becomes {null}
which will render nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is indeed true and a derp on my part. Disregard my comments ;)
Any plans to merge this? |
Yeah, this is a pretty weird bug - would be great to have this merged. |
The following will render "0":