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

Added the ability to import SVGs as a React Component #422

Merged
merged 3 commits into from
Jan 17, 2021
Merged

Added the ability to import SVGs as a React Component #422

merged 3 commits into from
Jan 17, 2021

Conversation

veighthedev
Copy link
Contributor

Added svgr as a loader for SVGs which allows you to import SVGs as Components.

https://react-svgr.com/docs/webpack/

@veighthedev
Copy link
Contributor Author

veighthedev commented Jan 16, 2021

Update: Made it using the old url-loader options in addition to the SVG loader

@loopmode
Copy link
Collaborator

Do I understand correctly that with this change, the default behavior does not change for existing projects? And that only if you use the named import explicitly you'll have the new behavior?

@veighthedev
Copy link
Contributor Author

veighthedev commented Jan 17, 2021

@loopmode yeah, the svg can still be imported as a url string, like it was before.

Example:

import starUrl, { ReactComponent as Star } from './star.svg'

const App = () => (
  <div>
    <img src={starUrl} alt="star" />
    <Star />
  </div>
)

@loopmode loopmode merged commit e46f37c into electron-userland:master Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants