-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add a checkbox to hide HOC wrappers in tree-view #503
Conversation
I'd really want to get something like this in, but I think it needs more work.
I don’t think this is a very good proxy. Any custom component that renders to another component would do that (which is very common in large apps). Instead, I would like to see blackboxing by regex. We could provide a reasonable default (e.g. components with There should also be a way to “discover” components are being blackboxed. For example, a |
@gaearon When I want to hide wrappers it's because I want to only see the components rendering actual DOM content. There might be a more generic/extensible/thorough way to do this, which I'm happy to discuss. But I'm glad we can start figuring out a solution. I also think it's valuable not to enforce a naming convention if possible. Hopefully others can weigh in their thoughts! |
I would not agree with this. For example, if you're using a company-wide component library with Blacklisting is useful, but I don’t think this is the right heuristic. |
I am torn regarding this. The simplicity of a checkbox to do this is enticing, but personally I feel it's important that the React DOM tree always reflect how it's different than the actual DOM. Thus, I am with @gaearon in desiring some UI feature to indicate the existence of HOCs or wrapping components. Perhaps instead of hiding, they were collapsed to |
Is it adding too much complexity / confusion to have both? |
To have both of what? I’m pretty sure, no matter what heuristic we use, |
I think that two options would be better than just a toggle:
which would be checked by default. in most of my use cases, I don't care at all about DOM nodes but I'm more interested in just seeing the HOC. |
@bloodyowl's idea is an interesting suggestion. HOCs are generally passing props into presentational components. Having the option to quickly hide or show both would make it easy to quickly inspect container or presentational components. |
The current implementation will only show presentational components and hide everything else. |
Could you perhaps only render components in a user's source directory? |
There is no concept of “presentational” components (or even “wrappers”) in React itself, and even if we were to use this distinction, it’s not what PR does ( I don’t think this is the right approach to solving this issue. I don’t think we can find a good heuristic for this. Browsers already support a very similar feature for callstacks: blackboxing. I think we should learn from that UI and apply the lessons here. It should be configurable and toggleable, just like in existing stack blackboxing UIs. |
It sounds like there's a need for more than one simple control. If there's differing opinions on what people want / need, can we just a more complicated input than a checkbox? |
Im so excited to see this! I mostly don't use the devtools anymore because the component stack is so deep it's silly to think of it s a tree :P I generally find I want to hide components for a two reasons:
so I agree it'd be nice to configure but I don't think a regex would cut it. Especially since app components usually wrap library components of the same name: Button -> ReactBootstrap.Button. I also think the HOC heuristic here is pretty good, but yes apps usually have tons of single child composed components that aren't the same sort of thing as like redux's connect() Sorry I don't have a proposal! just weighing tho :) |
In my previous comment I linked to an example showing how this could be done: blackboxing. Have you had a chance to check it out? I think we need to support something very similar (just replace "call frame" with "component" there). So, to extrapolate from that article, we could have:
|
An option that would cut down on wrappers, even if that's a vague concept, would help a lot. Often our components are wrapped either in redux connects or style wrappers, or both. It produces an overwhelming tree that doesn't resemble the JSX in the editor (using decorators). I find the definition of a HOC above reasonable. Showing components that produce dom as a filter would go a long way in taming the often noisy output. |
one, I think, important difference between the chrome blackboxing and component BBing tho. Its file based, vs say individual functions. Which is nice when you want to not see anything from node_modules, or from bootstrap.js. In this case if the regex is against |
One interesting thing @sebmarkbage suggested off the thread is we might be able to use |
Another interesting direction is using |
This sounds correct and these might be good approaches. Like others, I sometimes find that I ONLY want to see a particular HOC to introspect their local state. Sometimes I want to see just the DOM-rendering components. I'd love to see an approach that included regex-based source / owner / componentName filtering, but also basic heuristics like "does not render DOM" and "does render DOM" seem like they would be quite handy. |
Oh I like the |
@sebmarkbage How would we detect internal HOCs with __source? I'd be down for something simple like:
Then you could hide anything you want, have it persisted, and be able to turn it off with a checkbox. |
How about adjusting the visual styling so that HOC's have less (or more) contrast based on the various heuristics suggested above? |
The problem with |
@zackargyle Are you interested in trying to implement some of the ideas in this thread? I don’t think we’ll proceed with this particular version, but a more generic version of blackboxing would be amazing. |
@gaearon Yeah I can put something together, unless someone else would like to try. Got caught up with some work stuff, but I can work on it later this week. Agreed that it would be a great feature to have. |
I'm taking a whack at this |
@jaredly Right on! |
hmm hiding things from display is super easy, but the navigation code is not clean at all :( :( :( I think it wants some refactoring |
@jaredly any luck on this? Would still love to have something! |
kind ping @jaredly |
This issue has a huge importance for general HOC usage in the react community. Lots of people hesitate to use them because they introduce noise in the dev tools tree. |
Do you want to work on a more generic exclude mechanism? |
@gaearon me? I just recently discovered both issues, didn't think of any implementation details. |
Going to close this particular PR, but happy to see more generic solutions in #604. |
A pain point I've shared with many others is the congestion of the devtools tree when composing a large app with many HOCs. This PR introduces a "Hide Wrappers" checkbox that will hide all component wrappers from the tree view, instead showing only the tree of components that render at least some DOM content.
An HOC is determined to be any node that only returns a single child that is a non-DOM component.
Happy to talk about better ways of doing this, but I'd love to have something like available!