react2tree
v1.2.0
Published
Utility for mapping React component hierarchies to trees
Downloads
10
Maintainers
Readme
react2tree
Transform React component hierarchies to plain JavaScript tree structures.
Getting started
npm install react2tree
Usage
import React from 'react';
import react2tree from 'react2tree';
const myApp = React.render(<App/>, document.createElement('root'));
const tree = react2tree(myApp, 'myAppTree');
console.log(tree);
/*
{
name: "myAppTree",
children: [{
name: "RootComponentName",
children: [{
name: "Parent",
children: [{
name: "Child",
children: []
}, {
name: "OtherChild",
children: []
}]
}]
}]
}
*/