react-tree-walker
Advanced tools
Comparing version 2.0.0-alpha.3 to 2.0.0
{ | ||
"name": "react-tree-walker", | ||
"version": "2.0.0-alpha.3", | ||
"version": "2.0.0", | ||
"description": "Walk a React element tree, executing a provided function against each node.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -71,13 +71,18 @@ # react-tree-walker 🌲 | ||
* | ||
* @return `undefined` if you want to continue walking down the current branch, | ||
* or return `false` if you wish to stop the traversal down the | ||
* current branch. Stopping the traversal can be quite handy if | ||
* you want to resolve a Promise for example. You can wait for the | ||
* Promise to resolve and then execute a function to continue | ||
* traversal of the branch where you left off. | ||
* @return `true` to continue walking down the current branch, | ||
* OR | ||
* `false` if you wish to stop the traversal down the current branch, | ||
* OR | ||
* `Promise<true|false>` a promise that resolves to either true/false | ||
*/ | ||
function visitor(element, instance, context) { | ||
if (instance && typeof instance.getValue) { | ||
const value = instance.getValue() | ||
if (value === 4) { | ||
// stop traversal on this branch of tree. | ||
return false | ||
} | ||
values.push(instance.getValue()); | ||
} | ||
return true | ||
}; | ||
@@ -87,3 +92,3 @@ | ||
console.log(values); // [1, 2, 4, 5, 3]; | ||
console.log(values); // [1, 2, 4, 3]; | ||
``` | ||
@@ -90,0 +95,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
97
23701