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

fix: fix error when children include invalid element #286

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

AshoneA
Copy link

@AshoneA AshoneA commented Dec 30, 2019

fix error when first-level children include invalid element

@vercel
Copy link

vercel bot commented Dec 30, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

@@ -744,6 +744,9 @@ class Tree extends React.Component<TreeProps, TreeState> {
* We have to use `cloneElement` to pass `key`.
*/
renderTreeNode = (child, index, level = 0) => {
if (!React.isValidElement(child)) {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

should be return child?

Copy link
Author

Choose a reason for hiding this comment

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

If an element is invalid, I think there's no difference between child and null. return child should be also fine.

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