Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Conversation

@stonebk
Copy link

@stonebk stonebk commented Mar 8, 2017

The following will render "0":

const Foo = Dimensions()(() => <div />);
const Bar = () => {
    return <div style={{ width: 0, height: 0 }}><Foo /></div>;
};

<div style={wrapperStyle} ref='wrapper'>
{(containerWidth || containerHeight) &&
<ComposedComponent
{(containerWidth || containerHeight)
Copy link

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)

Copy link
Author

@stonebk stonebk Mar 13, 2017

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.

Copy link

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 ;)

@gabegorelick
Copy link

Any plans to merge this?

@yocontra
Copy link

Yeah, this is a pretty weird bug - would be great to have this merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants