diff --git a/README.md b/README.md index b1a0a81..1f9c5b5 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ const treeNodes = [ const getNodeData = (node, nestingLevel) => ({ data: { id: node.id.toString(), // mandatory - isLeaf: node.children.length === 0, + isLeaf: !!node.children, isOpenByDefault: true, // mandatory name: node.name, nestingLevel, @@ -95,6 +95,8 @@ function* treeWalker() { // the `getNodeData` function constructed, so you can read any data from it. const parent = yield; + if (!parent.node.children) continue + for (let i = 0; i < parent.node.children.length; i++) { // Step [3]: Yielding all the children of the provided component. Then we // will return for the step [2] with the first children.