首页 > 解决方案 > react-muuri 在运行 Gatsby Develop 和 Gatsby Build 时加载问题 Webpack

问题描述

react-muuri 组件出现 Webpack 错误、SSR 错误

无法解析“/luke_projects_all/Luke-site-calypsoBootstrap/calypso/gatsby-ld/node_modules/react-muuri/dist”中的“prop-types”

如果您尝试使用软件包,请确保安装了“prop-types”。如果您尝试使用本地文件,请确保路径正确。

文件:../../node_modules/react-muuri/dist/index.es.js:2:0

我将 react-muuri 组件放在代码拆分函数中,现在它可以工作了。我了解可加载组件已折旧。但它对我的情况有效。

import loadable from '@loadable/component'
const LoadableMuuriMaker = loadable(() => import('../components/muurimaker'))
function MyComponent() {
  return (
    <div>
      <LoadableMuuriMaker />
    </div>
  )
}

标签: gatsby-plugin

解决方案


推荐阅读