Skip to content

Update README.md #20

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

Merged
merged 5 commits into from
Apr 29, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function* treeWalker(refresh) {
const isOpened = yield refresh
? {
id,
isLeaf: children.length === 0,
isLeaf: children?.length === 0,
isOpenByDefault: true,
name,
nestingLevel,
Expand All @@ -93,13 +93,13 @@ function* treeWalker(refresh) {

// Basing on the node openness state we are deciding if we need to render
// the child nodes (if they exist).
if (node.children.length !== 0 && isOpened) {
if (children?.length !== 0 && isOpened) {
Copy link
Owner

Choose a reason for hiding this comment

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

The same situation as in the previous comment.

// Since it is a stack structure, we need to put nodes we want to render
// first to the end of the stack.
for (let i = node.children.length - 1; i >= 0; i--) {
for (let i = children?.length - 1; i >= 0; i--) {
Copy link
Owner

Choose a reason for hiding this comment

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

You forgot this one 🙂 It is not necessary to check since we already check it above.

stack.push({
nestingLevel: nestingLevel + 1,
node: node.children[i],
node: children[i],
});
}
}
Expand Down Expand Up @@ -253,18 +253,18 @@ function* treeWalker(refresh) {
// object.
defaultHeight: 30,
id,
isLeaf: children.length === 0,
isLeaf: children?.length === 0,
isOpenByDefault: true,
name,
nestingLevel,
}
: id;

if (node.children.length !== 0 && isOpened) {
for (let i = node.children.length - 1; i >= 0; i--) {
if (children && children.length !== 0 && isOpened) {
for (let i = children.length - 1; i >= 0; i--) {
stack.push({
nestingLevel: nestingLevel + 1,
node: node.children[i],
node: children[i],
});
}
}
Expand Down