Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide info about component tree to devtools #6549

Merged
merged 20 commits into from
Apr 26, 2016
Merged

Provide info about component tree to devtools #6549

merged 20 commits into from
Apr 26, 2016

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Apr 19, 2016

This is a work in progress that supersedes #6486 and #6488.

Unlike them, it doesn’t use an ID map and instead lets the core emit events as they happen.
(I should’ve started with this approach, it’s way simpler!)

I revert #6488 here because it is no longer necessary but can do this as a separate PR as well.

Things to do:

  • Update and unmount paths
  • Support and test server rendering

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@gaearon gaearon changed the title [WIP] Provide info about component tree to devtools Provide info about component tree to devtools Apr 20, 2016
@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

1 similar comment
@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@gaearon
Copy link
Collaborator Author

gaearon commented Apr 24, 2016

@sebmarkbage I removed isComposite and tried my best to hide TopLevelWrapper. I also noticed that I was cleaning up the information about unmounted instances too early, as I would need it in ReactPerf when the batch gets closed for analysis. This is why I tweaked it to only purge information on an explicit purgeUnmountedComponents() call, and in the result I made server rendering work the same way, and removed the need for passing native containers. Let me know if I missed some reason why they are important, but traversing the tree representation inside the devtool seems just as good to me, and makes the code clearer. I think this is ready now!

@facebook-github-bot
Copy link

@gaearon updated the pull request.

emitEvent('onSetDisplayName', debugID, displayName);
},
onSetIsEmpty(debugID, isEmpty) {
emitEvent('onSetIsEmpty', debugID, isEmpty);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this so the tree devtool would filter them out in getChildIDs. Alternatively I can go back to the old approach:

  • Make composite check for whether the rendered component is empty, and ignore it in onSetChildren
  • The tree devtool becomes unaware of parent-child association between composite and empty component so it can't clean it up on unmount easily
  • We have to add the native container IDs back so it's cleaned up on native container unmount instead

It feels like what I have now is simpler in terms of logic (all cleanup paths are the same and are caused by unmounting) but I can bring back native container tracking if it is more desirable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. I'd prefer if we could get rid of exposing this limitation because my reconciler just won't output any nodes for something that is empty. So I won't have this concept nor this limitation.

So it is exposing an implementation detail.

The tree devtool becomes unaware of parent-child association between composite and empty component so it can't clean it up on unmount easily

You can also just not expose it at all to the debug tool. That way it won't need to be cleaned up. Empty components doesn't have children or anything at all that is exposed.

So all you have to do is ignore any call to the debug tool that passes an instance of something "empty".

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@facebook-github-bot
Copy link

@gaearon updated the pull request.

@gaearon
Copy link
Collaborator Author

gaearon commented Apr 25, 2016

Ping @sebmarkbage, I would like to get this in asap because I’m stacking other work on top of this.

emitEvent('onSetIsEmpty', debugID, isEmpty);
},
onSetChildren(debugID, childDebugIDs) {
if (!isTopLevelWrapper(debugID)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this check to where you call .onSetChildren(...)?

The reason I want these gone is that my new reconciler won't have any of these limitations but it still wants to target this same ReactDebugTool.

@sebmarkbage
Copy link
Collaborator

I'll accept to avoid rebase problems but would be good to avoid exposing onSetIsEmpty (btw, if anything I think it is better to call them by a simple verb like onEmpty) and putting top level logic in the DebugTool.

@gaearon
Copy link
Collaborator Author

gaearon commented Apr 25, 2016

I’ll see what I can do there. Thanks!

@gaearon gaearon added this to the 15.x milestone Apr 26, 2016
@gaearon gaearon merged commit 76a4c46 into facebook:master Apr 26, 2016
@gaearon gaearon deleted the instrumentation-new branch April 26, 2016 00:12
zpao pushed a commit that referenced this pull request May 10, 2016
Provide info about component tree to devtools
(cherry picked from commit 76a4c46)
@zpao zpao modified the milestones: 15.1.0, 15.y.0 May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants