# react-tree-walker **Repository Path**: mirrors_jaydenseric/react-tree-walker ## Basic Information - **Project Name**: react-tree-walker - **Description**: Walk a React element tree - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-09-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # react-tree-walker 🌲 Walk a React element tree, executing a provided visitor function against each element. [](http://npm.im/react-tree-walker) [](http://opensource.org/licenses/MIT) [](https://travis-ci.org/ctrlplusb/react-tree-walker) [](https://codecov.io/github/ctrlplusb/react-tree-walker) ## TOCs - [Introduction](#introduction) - [Example](#example) - [FAQs](#faqs) ## Introduction Originally inspired/lifted from the awesome [`react-apollo`](https://github.com/apollostack/react-apollo) project. This modified version expands upon the design, making it `Promise` based, allowing the visitor to return a `Promise`, which would subsequently delay the tree walking until the `Promise` is resolved. The tree is still walked in a depth-first fashion. With this you could, for example, perform pre-rendering parses on your React element tree to do things like data prefetching. 🤛 # Example In the below example we walk the tree and execute the `getValue` function on every element instance that has the function available. We then push the value into a values array. ```jsx import reactTreeWalker from 'react-tree-walker'; class Foo extends React.Component { constructor(props) { super(props); this.getData = this.getData.bind(this); } getData() { // Return a promise or a sync value return Promise.resolve(this.props.value); } render() { return