babel-plugin-jsx-svg-import
add
svg
file imports forjsx
elements。
with svg-sprite-loader
Function
- There is no need to manually import the
svg
file, which automatically importsvg
in the file. - There is no need to provide a custom
Icon
component, the plugin can automatically import theIcon
component
options
"displayName": "Icon" "propName": "type" "directory": "/assets/" "importComponent": false
no use [importComponent]
'babel-plugin-jsx-svg-import' displayName: 'Icon' propName: 'type' directory: '/assets/' ;
; ReactDOM; ↓ ↓ ↓ ↓ ↓ ↓ ReactDOM;
use importComponent
'babel-plugin-jsx-svg-import' displayName: 'Icon' propName: 'type' directory: '/assets/' importComponent: true ;
ReactDOM; ↓ ↓ ↓ ↓ ↓ ↓ ; ReactDOM;
Icon Component
from antd Icon
prop | desc | type | default |
---|---|---|---|
width | svg element width |
string | number | '1em' |
height | svg element height |
string | number | '1em' |
fill | svg element fill color |
string | 'currentColor' |
className | svg element class |
string | - |
style | svg element style |
CSSProperties | - |