When using @svgr/webpack, the generated React components for SVGs still include defaultProps, which results in the following warning in the console when using React.
"Warning: Component.defaultProps is not supported in React future releases. Use JavaScript default parameters instead."
I've tried various approches to reolve but no luck till now.
currently i'm using this config for the svgr/webpack
// svgr.config.js
{
expandProps: ,false
replaceAttrValues: {},
prettier: true,
typescript: true, // if you're using TypeScript
jsxRuntime: 'automatic', // or 'classic' depending on your setup
// Disable defaultProps
svgo: true,
svgoConfig: {
plugins: [
{
name: 'removeViewBox',
active: false,
},
],
},
template: (variables, { tpl }) => {
return tplimport * as React from 'react'; const ${variables.componentName} = ({ title = "default title", ...props }) => ( ${variables.jsx} ); export default ${variables.componentName};;
}
};
When using @svgr/webpack, the generated React components for SVGs still include defaultProps, which results in the following warning in the console when using React.
"Warning: Component.defaultProps is not supported in React future releases. Use JavaScript default parameters instead."
I've tried various approches to reolve but no luck till now.
currently i'm using this config for the svgr/webpack
// svgr.config.js
{
expandProps: ,false
replaceAttrValues: {},
prettier: true,
typescript: true, // if you're using TypeScript
jsxRuntime: 'automatic', // or 'classic' depending on your setup
// Disable defaultProps
svgo: true,
svgoConfig: {
plugins: [
{
name: 'removeViewBox',
active: false,
},
],
},
template: (variables, { tpl }) => {
return tpl
import * as React from 'react'; const ${variables.componentName} = ({ title = "default title", ...props }) => ( ${variables.jsx} ); export default ${variables.componentName};;}
};