-
Notifications
You must be signed in to change notification settings - Fork 171
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
Improve defaultChildNode #317
Improve defaultChildNode #317
Conversation
} else if (children && children.length > 0) { | ||
return children[0].pathSegment; | ||
} else if (children && children.length) { | ||
const validChild = children.find( |
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.
Not reviewing it, but saw it and would like to give feedback. I would rewrite is as
const validChild = children.find(
child => child.pathSegment && (child.viewUrl || (child.externalLink && child.externalLink.url))
);
return validChild ? validChild.pathSegment : '';
Otherwise imo is like checking partially in the return statement if the validChild
is valid, which doesn't make much sense
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.
I like it and I'll apply it 👍
Improve defaultChildNode
Description
Changes proposed in this pull request:
Related issue(s)