ctrlplusb / react-tree-walker

Walk a React (or Preact) element tree, executing a "visitor" function against each element.
MIT License
345 stars 34 forks source link

Support Shallow Walk #2

Closed amccloud closed 6 years ago

amccloud commented 7 years ago

It would be nice if you can optionally walk children only.

One way to do this is to have visitor function optionally return an array of elements to walk next. If it's type Array I think you can assume it is children and proceed with a breadth-first walk.

Example use case: https://github.com/amccloud/await-component

ctrlplusb commented 7 years ago

Is there any chance you could create a more isolated example / test of what you are trying to achieve?