Storybook + React: значок SVG вызывает недопустимый тип элемента: ожидается строка (для встроенных компонентов) или класс / функция - PullRequest
0 голосов
/ 19 июня 2020

У меня есть компонент React:

import React from 'react';



import { ReactComponent as IncreaseIcon } from '../icons/increase.svg';



const StatCard = ({
  className,
  value,
  percentChange,
  description,
  tooltipDescription
}) => (
  <Container className={className}>
    ...
      <h1>
        <IncreaseIcon />
        123%
      </h1>
    ...
  </Container>
);

export default StatCard;

Сам компонент работает, когда я загружаю его в свое приложение React, но когда я пытаюсь загрузить его в сборник рассказов, он терпит неудачу:

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.

Дело в том, что если я удалю <IncreaseIcon /> из компонента, он будет работать нормально.

Это мой пакет. json

{
  "name": "@myapp/ui",
  "version": "0.2.8-beta.8",
  "dependencies": {
    "@ant-design/icons": "^4.2.1",
    "@fullcalendar/core": "^4.3.1",
    "@fullcalendar/daygrid": "^4.3.0",
    "@fullcalendar/react": "^4.3.0",
    "antd": "^3.26.7",
    "clone": "^2.1.2",
    "react": "^16.13.1",
    "react-dom": "^16.12.0",
    "react-draft-wysiwyg": "^1.14.4",
    "react-text-mask": "^5.4.3",
    "recharts": "^1.8.5",
    "styled-components": "^4.4.1",
    "styled-theme": "^0.3.3"
  },
  "scripts": {
    "start": "start-storybook -p 9009",
    "eslint": "eslint --ignore-path .gitignore ./",
    "eslint:fix": "eslint --fix --ignore-path .gitignore ./"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/preset-env": "^7.8.3",
    "@storybook/addon-actions": "^5.3.4",
    "@storybook/addon-knobs": "^5.3.4",
    "@storybook/addon-links": "^5.3.4",
    "@storybook/addon-viewport": "^5.3.4",
    "@storybook/addons": "^5.3.4",
    "@storybook/preset-create-react-app": "^1.5.1",
    "@storybook/react": "^5.3.4",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^7.1.5",
    "babel-plugin-styled-components": "^1.10.6",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.10.0",
    "eslint-plugin-jest": "^23.6.0",
    "eslint-plugin-json": "^2.0.1",
    "eslint-plugin-prettier": "^3.1.2",
    "eslint-plugin-react": "^7.19.0",
    "husky": "^4.2.1",
    "jest": "^25.1.0",
    "prettier": "^1.19.1"
  },
  "husky": {
    "hooks": {
      "pre-push": "npm run eslint"
    }
  }
}

Почему сломано?

...