我有一个 Next.js 12.1.4 项目,使用 Typescript、React 测试库和 SVGR 来导入如下图标:import ChevronLeftIcon from './chevron-left.svg'
我遇到的问题是,当我运行包含 SVG 导入的组件测试时,出现以下错误:
console.error
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `Loader`.
at Loader (.../src/components/atoms/Loader/Loader.tsx:11:36)
at div
at button
at Button (.../src/components/atoms/buttons/Button/Button.tsx:19:5)
15 | }`}
16 | >
> 17 | <LoaderIcon />
| ^
18 | </div>
19 | )
20 |
at printWarning (node_modules/react/cjs/react-jsx-runtime.development.js:117:30)
at error (node_modules/react/cjs/react-jsx-runtime.development.js:93:5) …Run Code Online (Sandbox Code Playgroud)