Skip to content
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

Wrap children if it's single-element array #70

Merged
merged 1 commit into from
Nov 22, 2016
Merged

Wrap children if it's single-element array #70

merged 1 commit into from
Nov 22, 2016

Conversation

skydan
Copy link
Contributor

@skydan skydan commented Nov 22, 2016

Spotted a bug today when passing single-element array as a children to MediaQuery causes error.
Multi-element arrays work fine, so this one looks like edge case.

@@ -94,6 +94,7 @@ export default class MediaQuery extends React.Component {
const wrapChildren = this.props.component ||
childrenCount > 1 ||
typeof this.props.children === 'string' ||
Array.isArray(this.props.children) && childrenCount == 1 ||
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for childrenCount check? Array.isArray should be fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this test fails without this check.

@yocontra yocontra merged commit 2badbdc into yocontra:master Nov 22, 2016
@yocontra
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants