【发布时间】:2020-06-17 00:39:32
【问题描述】:
我正在尝试在我的 Gatsby.js 项目中包含 svg 文件。
LogoIcon 组件是这样的:
import React from 'react';
import { ReactComponent as LogoInstagram } from '../assets/img/instagram-logo.svg';
const LogoIcon = () => {
return (
<div>
{}
<LogoInstagram />
</div>
);
};
export default LogoIcon;
我收到此错误:
Error: Element type is invalid: expected a string (for built-in components) or a
class/function (for composite components) but got: undefined. You likely forgot to export
your component from the file it's defined in, or you might have mixed up default and named
imports.
Check the render method of `LogoIcon`.
▶ 20 stack frames were collapsed.
(anonymous function)
/website/.cache/app.js:67
64 | const preferDefault = m => (m && m.default) || m
65 | let Root = preferDefault(require(`./root`))
66 | domReady(() => {
> 67 | renderer(<Root />, rootElement, () => {
68 | apiRunner(`onInitialClientRender`)
69 | })
70 | })
它与 SVG 文件有关还是我遗漏了什么?
【问题讨论】: