在 svg 组件上运行测试时收到警告。它不会导致测试失败,而是试图将其清理干净。使用 SVGR 使用 svg 文件作为 React 组件。我相信问题是 Jest 无法看到 webpack 中的 svgr 配置,但不知道如何修复它。
警告
console.error
Warning: <ReactComponent /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
at ReactComponent
at Icon (/code/common/javascript/components-2.0/lib/brand/Icon/index.tsx:9:11)
Run Code Online (Sandbox Code Playgroud)
import { SvgIndexable } from "./Icon.types";
import { ReactComponent as ArrowRight } from "./svg/arrow-right.svg";
const iconNames: SvgIndexable = {
"arrow-right": ArrowRight,
}
export default iconNames
Run Code Online (Sandbox Code Playgroud)
索引.js
import React from "react";
import className from "classnames";
import { IconTypes } from "./Icon.types";
import …Run Code Online (Sandbox Code Playgroud)