【发布时间】:2019-02-09 02:17:49
【问题描述】:
我有一个Icon.jsx 组件:
import React from 'react'; import { css } from 'emotion';
import ArrowRight from "./arrow-right.svg";
export const iconTypes = {
arrowRight: 'ARROW_RIGHT',
//arrowLeft: "ARROW_LEFT", }
const iconSrc = {
ARROW_RIGHT: ArrowRight,
ARROW_LEFT: ArrowLeft, }
export default ({ type }) => {
return (
<Icon>
<img src={iconSrc[type]} />
</Icon>
)
};
还有一个“Icon.jsx”的故事:
import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import Icon from "../components/Icon/Index";
import { iconTypes } from "../components/Icon/Index";
storiesOf("Icon", module)
.add("with text", () => (
<Icon type={iconTypes.leftArrow}>
</Icon>
));
我在Icon.jxs 组件上不断收到以下错误:
Property value expected type of string but got null
但我想不通,任何帮助将不胜感激。
【问题讨论】:
-
'ArrowLeft' 未在您的代码中定义(ArrowRight 指的是 svg 文件)
标签: reactjs