Skip to content

Commit

Permalink
Preps v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed Mar 16, 2018
1 parent 5677d18 commit 67b500f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Foo extends React.Component {
}

getData() {
// Return a promise or a sync value
// Return a promise or a sync value
return Promise.resolve(this.props.value);
}

Expand Down Expand Up @@ -66,10 +66,10 @@ const values = [];
* @param instance - If the current element is a Component or PureComponent
* then this will hold the reference to the created
* instance. For any other element type this will be null.
* @param context - The current "React Context". Any provided childContexTypes
* @param context - The current "React Context". Any provided childContextTypes
* will be passed down the tree.
*
* @return `true` to continue walking down the current branch,
* @return Anything other than `false` to continue walking down the current branch
* OR
* `false` if you wish to stop the traversal down the current branch,
* OR
Expand All @@ -80,18 +80,18 @@ function visitor(element, instance, context) {
return instance.getData()
.then((value) => {
values.push(value);
return value === 4
// prevent traversing "4"'s children
? false
: true
// Return "false" to indicate that we do not want to traverse "4"'s children
return value !== 4
})
}
return true
}

reactTreeWalker(app, visitor).then(() => {
console.log(values); // [1, 2, 4, 3];
});
reactTreeWalker(app, visitor)
.then(() => {
console.log(values); // [1, 2, 4, 3];
})
// since v3.0.0 you need to do your own error handling!
.catch(err => console.error(err));

```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-tree-walker",
"version": "2.2.0",
"version": "3.0.0",
"description":
"Walk a React element tree, executing a provided function against each node.",
"license": "MIT",
Expand Down

0 comments on commit 67b500f

Please sign in to comment.