Comments (10)
No, but this does.
https://babeljs.io/docs/en/babel-plugin-transform-react-display-name
from babel-plugin-add-react-displayname.
@gajus -- the documentation for that one doesn't look like it supports Functional Components -- is that true?
from babel-plugin-add-react-displayname.
You are right.
Come to think about it, I cannot think of how this could be implemented.
from babel-plugin-add-react-displayname.
To be honest, I'd be fine with a transform that attaches displayName
to every loose function/arrow-function in a JSX-enabled file (.tsx
in my project). Presumably that would make it easier? (I'm just a babel newbie)
from babel-plugin-add-react-displayname.
Any update on this? I would be happy to work on dev for a plugin that does work in v7, but don't want to duplicate work if such a thing already exists. Would be very grateful for any tips/advice.
from babel-plugin-add-react-displayname.
It looks like I have sometime ago released a plugin to solve this problem.
https://github.com/gajus/babel-plugin-react-display-name
from babel-plugin-add-react-displayname.
@gajus Yes, but that only covers createClass
, right? Very few people are writing new React code like that.
from babel-plugin-add-react-displayname.
Good point. I haven't touched that code for a long time.
https://github.com/gajus/babel-plugin-transform-export-default-name
This would work for default exports, though.
from babel-plugin-add-react-displayname.
Okay, that's good reference to have. My particular use case requires use of named exports. Are you aware of any way of statically determining the return type of a function (eg jsx) within a Babel plugin?
If that's possible, it should be pretty straightforward to loop over all exports and append displayName
as necessary.
from babel-plugin-add-react-displayname.
Okay, that's good reference to have. My particular use case requires use of named exports. Are you aware of any way of statically determining the return type of a function (eg jsx) within a Babel plugin?
I am not. I don't think that is possible either (accurately), unless you are using strict types (like Flow or TS).
from babel-plugin-add-react-displayname.
Related Issues (8)
- Unable to run test suite HOT 4
- Doesn't work with "modern" transpilation HOT 1
- The plugin does not work if the (functional) component returns a Fragment within a forwardRef HOT 1
- License? HOT 1
- NPE on return statement with no argument HOT 1
- Adds displayName to components that already have it
- "Unknown" displayName values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-add-react-displayname.