1. @svgr/plugin-jsx
Transform SVG into JSX
@svgr/plugin-jsx
Package: @svgr/plugin-jsx
Created by: gregberge
Last modified: Tue, 15 Aug 2023 06:46:22 GMT
Version: 8.1.0
License: MIT
Downloads: 33,400,984
Repository: https://github.com/gregberge/svgr

Install

npm install @svgr/plugin-jsx
yarn add @svgr/plugin-jsx

@svgr/plugin-jsx

Build Status
Version
MIT License

Transforms SVG into JSX.

Install

npm install --save-dev @svgr/plugin-jsx

Usage

.svgrrc

 {
  "plugins": ["@svgr/plugin-jsx"]
}

How does it work?

@svgr/plugin-jsx consists in three phases:

Applying custom transformations

You can extend the Babel config applied in this plugin using jsx.babelConfig config path:

 // .svgrrc.js

module.exports = {
  jsx: {
    babelConfig: {
      plugins: [
        // For an example, this plugin will remove "id" attribute from "svg" tag
        [
          '@svgr/babel-plugin-remove-jsx-attribute',
          {
            elements: ['svg'],
            attributes: ['id'],
          },
        ],
      ],
    },
  },
}

Several Babel plugins are available:

If you want to create your own, reading Babel Handbook is a good start!

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code