-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
Always prefix component name with Svg
#190
Comments
I think, that prefix should be configurable. With possibility to opt-out completely. |
What is the use case of configuring it? |
Yeah, maybe configuring is an overhead) But opting-out would be nice. In my project all svgs already have 'Icon' prefix. |
The name doesn't have any impact expect in React inspector 🤷♂️ |
Ok, you're right) Withdrawing my request) |
Took me some time to understand the why, even with the linked issues, so here are some more details: JavaScript is a forgiving language, allowing you to overwrite global objects, properties and methods. E.g., a component can be named import Math from "./Math";
function App() {
console.log(Math.random());
return (
<div>
<Math />
</div>
);
} However, this would break above component, which uses at the same time I.e. - having a prefix is required to prevent conflicts. |
It does have affect when using it with Storybook |
It increases the readability of the code. |
Please add this simple feature. Having a prefix would massively improve developer experience with auto imports without having to rename every single source file (which can frequently change). Customizing component templates is simple enough, but customizing exports and index templates requires more work from the user than it would be to add one switch to the command or config. |
As discussed in #168, the component name generated could be a problem with some filename. For an example, "infinity.js" will generate "Infinity" that is a reserved keyword.
The simplest solution is to prefix all component name with
Svg
. We already do it for "number" filenames.The text was updated successfully, but these errors were encountered: