-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
__source makes component stack less useful #12058
Comments
There is a PR that improves this: #11523. I'm not sure we'll want to take that particular approach. However maybe we can just add a special case for |
i.e. I am proposing that if the filename is |
I’m not sure really. I’m worried this might make the warnings way too long on projects with a lot of folder nesting. I would prefer that we do the smaller fix first and then maybe look at it again. |
Ok, I will submit a PR for the smaller fix. Thanks for the discussion! Incidentally, while looking into whether I should enable |
It’s not used yet. The plan was to use it to see where callback ref owner would be different from a string ref owner. That would be useful if we deprecated string refs. We have a different plan for that now though. |
Do you want to request a feature or report a bug?
Somewhere in between.
What is the current behavior?
When I enable
babel-plugin-transform-react-jsx-source
to automatically add a__source
prop to every component in development, the component stack displayed for certain React warnings changes from displaying the (inferred) name of the rendering component to displaying the filename and line number of the occurrence.React also has access to the file path, but it is stripped and only the filename is included. This seems to be based on the assumption that the name of a file always maps exactly to the name of the component it exports. In practice, many people place components in
ComponentName/index.js
, so__source
currently makes the stack less useful.For example, compare:
to:
What is the expected behavior?
I would like the stack to include the full file path, or at least to include the inferred component name alongside the filename.
Would you accept a PR for either option?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.2.0. This was introduced in #6771 for 15.2.0.
The text was updated successfully, but these errors were encountered: