Support React `__source` prop
See original GitHub issueInitial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
React uses the __source
prop display where components originate in the React devtools.
Babel supports this in @babel/babel-plugin-transform-react-jsx-source
.
Solution
Inject this prop in a similar way as @babel/babel-plugin-transform-react-jsx-source
. This should only happen in development and only for React, but optionally supporting alternative runtimes.
Also I’m willing to implement this.
Alternatives
It could be an external recma plugin, but I think it’s useful to include in core.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How to Use React Props with Source Code [Beginners Guide]
"Props" is a special keyword in React which is used for passing data from one component to another. Read this article to know...
Read more >Context - React
Context provides a way to pass data through the component tree without having to pass props down manually at every level. In a...
Read more >React Top-Level API
Today, Suspense only supports one use case: loading components ... Component API Reference for a list of methods and properties related to the...
Read more >Refs and the DOM - React
In the typical React dataflow, props are the only way that parent components ... React also supports another way to set refs called...
Read more >Integrating with Other Libraries - React
The <div /> element has no properties or children, so React has no reason to update it, leaving the jQuery plugin free to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
AST explorer only attaches start and end offsets, but apparently the estree format produced by MDX attaches
loc
as well. So you’re right, we don’t need any additional information, at least not for MDX.I found a bit more info in the React RFC for the automatic runtime.
So basically in the classic runtime, we need to compile to:
And in the automatic runtime, we need to compile to the following, where
isStaticChildren
is a boolean indicating if a production runtime would usejsxs
instead ofjsx
:I still need to figure out when the
__self
prop or last argument of_jsxDEV
needs to be added. It could be added later as well, so I can focus on supporting__source
first.I also believe this shows this functionality belongs in core, especially for the automatic runtime.