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
Implement "view React component source" #8708
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
7523b84
to
5ded12b
Compare
|
|
57 replays were recorded for 64b8080.
|
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! This is great!
Looks like an RDT integration test is failing though. Didn't look at it but we should make sure it's not a regression before landing.
|
Yeah, I'll review that one in the morning. |
|
Test definitely fails for me locally, so I broke something. Investigating... |
- Refactored `createReactDevtools` setup to make `wall` available - Added `viewSource` prop - Added logic to tell the RDT backend to save the component instance, then fetch the function reference via the protocol
5ded12b
to
64b8080
Compare
|
Apparently wrapping |






The React DevTools UI has support for "view component source". Provide an appropriate callback prop, and the RDT logic will give you the ID of the selected component. From there, you can talk to the RDT "backend" logic, send it a
"viewElementSource"message, and it will save a reference to the component aswindow.$type. We can then evaluate code in the paused browser to retrieve that function reference, and do our usual "map the location and jump to the source" steps.For function components, it jumps straight to the function. For class components, it jumps to
render(). This behavior came straight from the extension:https://github.com/facebook/react/blob/v18.0.0/packages/react-devtools-extensions/src/main.js#L194-L220
Results: