【问题标题】:Gatsby's StaticImage not rendering in StorybookGatsby 的 StaticImage 未在 Storybook 中呈现
【发布时间】:2021-09-14 18:09:37
【问题描述】:

我正在尝试使用 Gatsby 的 StaticImage 为我的组件编写故事书,但这最终没有呈现任何内容,并且在控制台中伪装成警告的错误:

Please ensure that "gatsby-plugin-image" is included in the plugins array in gatsby-config.js, and that your version of gatsby is at least 2.24.78
(anonymous) @ static-image.server.tsx:52

我想知道是否有办法在 Gatsby 之外使用 StaticImage 渲染组件?

组件是微不足道的:

import React from 'react';
import { StaticImage } from 'gatsby-plugin-image';

export const Card = ({ title }) => {
  return (
    <div>
      <div>{title}</div>
      <StaticImage src="../../assets/images/background.png" alt="" width={300} height={100}/>
    </div>
  );
};

我正在使用 Gatsby v3 和 Storybook v6.3

【问题讨论】:

    标签: javascript gatsby storybook


    【解决方案1】:

    基于Gatsby Documentation,目前尚不支持。

    注意:目前不支持为使用来自 gatsby-plugin-image 的 StaticImage 的组件编写故事。欢迎为实现这一目标做出贡献。

    【讨论】:

    • 谢谢,我没有意识到这一点!显然是时候迁移到 next.js...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 2020-03-05
    • 2021-09-20
    • 2021-04-05
    • 2021-02-15
    • 2021-12-09
    • 2021-01-07
    相关资源
    最近更新 更多