Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Fixed error if there are no children in the header #22

Merged
merged 1 commit into from
Sep 25, 2015

Conversation

Graf009
Copy link

@Graf009 Graf009 commented Aug 28, 2015

Fixed error if there are no children in the header

@tleunen
Copy link
Owner

tleunen commented Aug 28, 2015

Not sure about this one... If the component doesn't have any children, it should not go inside the forEach loop.

@Graf009
Copy link
Author

Graf009 commented Aug 28, 2015

Example:

{!userIsLogin && LOG IN} // return false

@tleunen
Copy link
Owner

tleunen commented Aug 28, 2015

Hmm. Would need to test this one myself. Could be a React issue then, I'm not sure we should be able to loop over a false child. (https://facebook.github.io/react/tips/false-in-jsx.html)

@Graf009
Copy link
Author

Graf009 commented Aug 31, 2015

<Header transparent title="Example">
        {!userIsLogin && <Button raised colored onClick={ onLoginButton }>LOG IN</Button>}
</Header>

In article https://facebook.github.io/react/docs/component-specs.html says "You can also return null or false to indicate that you don't want anything rendered."
I think it's safe behavior, what do you say?

@tleunen
Copy link
Owner

tleunen commented Aug 31, 2015

I had a crazy weekend so I didn't get the chance to take a look at this.
Would probably need to put a breackpoint in this traverseAllChildren and see what's going on :)
https://github.com/facebook/react/blob/master/src/shared/utils/traverseAllChildren.js

@tleunen
Copy link
Owner

tleunen commented Sep 13, 2015

I finally got time to check this one, and I can not reproduce the issue. If the Header doesn't have any children, the children property is undefined and therefore it goes never inside the children.foreach function.

@tleunen tleunen closed this Sep 13, 2015
@Graf009
Copy link
Author

Graf009 commented Sep 17, 2015

Here is an example that reproduces the error https://gist.github.com/Graf009/ddef4109d157046ac62a

@tleunen tleunen reopened this Sep 25, 2015
tleunen added a commit that referenced this pull request Sep 25, 2015
Fixed error if there are no children in the header
@tleunen tleunen merged commit 871c46e into tleunen:master Sep 25, 2015
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.

None yet

2 participants