Closed dahaca closed 1 year ago
Can you share the contents of the file that causes the error?
It was happening in all files. In one React component, I tried removing the SVG component and the error referenced another file the next time.
When it comes to the SVG it was used like that:
import Gear from '../../../public/icons/gear.svg'
...
const GearIcon = styled(Gear)`
width: 2rem;
`
...
<IconContainer onClick={() => setIsOpened(current => !current)}>
<GearIcon />
</IconContainer>
The SVG does have a style
prop and always had - saw it was causing a problem in another issue.
Can you share the full error message you receive, including line numbers?
hey there, same here. doesn't seem to work for any of the components.
Property value of ObjectProperty expected node to be of a type ["Expression","PatternLike"] but instead got "JSXExpressionContainer"
at Object.validate (/mnt/c/Users/karam/work/marvl/front/node_modules/@babel/core/node_modules/@babel/types/lib/definitions/utils.js:132:11)
at validateField (/mnt/c/Users/karam/work/marvl/front/node_modules/@babel/core/node_modules/@babel/types/lib/validators/validate.js:24:9)
at validate (/mnt/c/Users/karam/work/marvl/front/node_modules/@babel/core/node_modules/@babel/types/lib/validators/validate.js:17:3)
at builder (/mnt/c/Users/karam/work/marvl/front/node_modules/@babel/core/node_modules/@babel/types/lib/builders/builder.js:40:27)
at Object.objectProperty (/mnt/c/Users/karam/work/marvl/front/node_modules/@babel/core/node_modules/@babel/types/lib/builders/generated/index.js:399:31)
at /mnt/c/Users/karam/work/marvl/front/node_modules/babel-plugin-inline-react-svg/lib/index.js:135:33
at Array.forEach (<anonymous>)
at applyPlugin (/mnt/c/Users/karam/work/marvl/front/node_modules/babel-plugin-inline-react-svg/lib/index.js:131:43)
at PluginPass.ImportDeclaration (/mnt/c/Users/karam/work/marvl/front/node_modules/babel-plugin-inline-react-svg/lib/index.js:201:11)
at newFn (/mnt/c/Users/karam/work/marvl/front/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:175:21)
hmm, that's coming from https://github.com/airbnb/babel-plugin-inline-react-svg/blob/master/src/index.js#L103.
@kodedninja any idea what code of yours it's breaking on?
@ljharb sorry, no idea. i don't do anything special with it though, but here's my config if that helps (it's still in the 1.*
format).
plugins: [
{
removeAttrs: {
attrs: '(data-name)',
},
},
{
prefixIds: true,
},
{
removeViewBox: false,
},
{
removeTitle: false,
},
]
Looks like prefixIds plugin doesn't work with svg's with style
property
https://github.com/airbnb/babel-plugin-inline-react-svg/issues/76#issuecomment-616313298
After upgrading I am getting the following error:
I am using Next.js + TS. When I roll back to 1.1.2 everything works fine, no changes to .svg files made.