Skip to content
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

Closed
gregberge opened this issue Sep 26, 2018 · 9 comments
Closed

Always prefix component name with Svg #190

gregberge opened this issue Sep 26, 2018 · 9 comments

Comments

@gregberge
Copy link
Owner

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.

@smashercosmo
Copy link

I think, that prefix should be configurable. With possibility to opt-out completely.

@gregberge
Copy link
Owner Author

What is the use case of configuring it?

@smashercosmo
Copy link

Yeah, maybe configuring is an overhead) But opting-out would be nice. In my project all svgs already have 'Icon' prefix.

@gregberge
Copy link
Owner Author

The name doesn't have any impact expect in React inspector 🤷‍♂️

@smashercosmo
Copy link

Ok, you're right) Withdrawing my request)

@PenguinDetective
Copy link

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 Math or Infinity

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 Math.random(). JavaScript sees Math not as the built-in math function but as a JSX element.

I.e. - having a prefix is required to prevent conflicts.

@dheerajsinghnagdali
Copy link

The name doesn't have any impact expect in React inspector 🤷‍♂️

It does have affect when using it with Storybook

@TryV
Copy link

TryV commented May 5, 2024

What is the use case of configuring it?

It increases the readability of the code.

@GlitchedCode
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants