gohypergiant / react-component-hierarchy

A CLI app for visualizing how React components are structured in a project.
https://medium.com/bpxl-craft/introducing-react-component-hierarchy-35d5cc4d3782
MIT License
119 stars 25 forks source link

rch prints undefined/index #13

Open mattiaerre opened 5 years ago

mattiaerre commented 5 years ago

Context

What are you trying to achieve or the steps to reproduce?

npx react-component-hierarchy -c ./index.js

What were your results?

npx: installed 14 in 4.054s
undefined/index

What did you expect?

To see my components' tree

mattiaerre commented 5 years ago

also if I run:

npx react-component-hierarchy app.js

I've got this output:

npx: installed 14 in 2.994s
colors[(node.depth || 0)] is not a function
mattiaerre commented 5 years ago

it looks like the issue is in the github:surreal9/pretty-tree package; if the app has got node w/ depth >= colors.length - 1 it throws the above error. so either this package uses the unforked pretty-tree or the forked version should be fixed w/ something like:

before

colors[node.depth || 0](node.label);

after

colors[node.depth % colors.length](node.label);

// cc @Surreal9

arshmakker commented 5 years ago

am getting the same issue. +1 for that

brookemahoney commented 5 years ago

I forked this and then forked pretty-tree, made the suggested change from above, and it solved this. https://github.com/jeffymahoney/react-component-hierarchy