-
Notifications
You must be signed in to change notification settings - Fork 26
Add annotations of our React components to the DOM in dev builds #664
Comments
cc'ing @jrbenny35 for his thoughts on this. Are there any negative implications that you think of that might outweigh the benefits of using this solution? |
I like this, and it should help quite a bit. |
I've forgotten, did we discuss this during the meeting? I'm beginning to seeing anecdotal usage of |
In the meeting, I think I just brought up how it'd be nice if there were a way to get the React component names into the DOM and that there was probably a tool to do it, but that if there were no tool we could do it manually. This is one such tool, and it should be really easy to integrate into our build system. |
Ok, I tested it out, and this tool isn't quite what we need, but it can probably form a base for something that we could use. There are a couple problems:
|
Another option is to manually annotate with a particular prop and then strip that prop from prod builds via As for why we'd strip it in prod, the main reason is for optimization purposes (same reason we minify our source in prod). This would be a smaller optimization than stripping auto-generated props, so it might not be worth it, but every little bit helps, especially since JSX compiles to some fairly verbose code. |
Here's a (possibly) better option: instead of trying to use a common attribute name to store this metadata, we could have a unique attribute name for every React component. For example, we'd end up with something like this:
Then it's easy to automatically inject these names via Babel. |
@m8ttyB Does the above sound usable for the integration tests? It should be pretty easy to whip up a Babel plugin that does that. |
@jimporter I can't find a fault with this. Does the extra information help you debug a problem once a bug is filed? |
https://github.com/suprraz/babel-plugin-react-element-info
It should make it a lot easier to write integration tests for our UI! :)
The text was updated successfully, but these errors were encountered: