@@ -35,7 +35,7 @@ class Foo extends React.Component {
3535 }
3636
3737 getData () {
38- // Return a promise or a sync value
38+ // Return a promise or a sync value
3939 return Promise .resolve (this .props .value );
4040 }
4141
@@ -66,10 +66,10 @@ const values = [];
6666 * @param instance - If the current element is a Component or PureComponent
6767 * then this will hold the reference to the created
6868 * instance. For any other element type this will be null.
69- * @param context - The current "React Context". Any provided childContexTypes
69+ * @param context - The current "React Context". Any provided childContextTypes
7070 * will be passed down the tree.
7171 *
72- * @return `true ` to continue walking down the current branch,
72+ * @return Anything other than `false ` to continue walking down the current branch
7373 * OR
7474 * `false` if you wish to stop the traversal down the current branch,
7575 * OR
@@ -80,18 +80,18 @@ function visitor(element, instance, context) {
8080 return instance .getData ()
8181 .then ((value ) => {
8282 values .push (value);
83- return value === 4
84- // prevent traversing "4"'s children
85- ? false
86- : true
83+ // Return "false" to indicate that we do not want to traverse "4"'s children
84+ return value !== 4
8785 })
8886 }
89- return true
9087}
9188
92- reactTreeWalker (app, visitor).then (() => {
93- console .log (values); // [1, 2, 4, 3];
94- });
89+ reactTreeWalker (app, visitor)
90+ .then (() => {
91+ console .log (values); // [1, 2, 4, 3];
92+ })
93+ // since v3.0.0 you need to do your own error handling!
94+ .catch (err => console .error (err));
9595
9696```
9797
0 commit comments