【问题标题】:WebpackError: TypeError: Cannot read property 'store' of nullWebpackError:TypeError:无法读取 null 的属性“存储”
【发布时间】:2020-12-13 20:39:16
【问题描述】:

我只是一个编程新手,刚刚尝试了几个月的 GatsbyJs。我运行了命令“gatsby build”,这是出现的错误,它在“gatsby develop”上运行良好。

1:24:14 AM: failed Building static HTML for pages - 12.853s
1:24:14 AM: error Building static HTML failed for path "/products/"
1:24:14 AM: 
1:24:14 AM:   101 | 
1:24:14 AM:   102 |     var _useReduxContext = useReduxContext(),
1:24:14 AM: > 103 |         store = _useReduxContext.store,
1:24:14 AM:       | ^
1:24:14 AM:   104 |         contextSub = _useReduxContext.subscription;
1:24:14 AM:   105 | 
1:24:14 AM:   106 |     var selectedState = useSelectorWithStoreAndSubscription(selector, equalityFn, store, contextSub);
1:24:14 AM: 
1:24:14 AM:   WebpackError: TypeError: Cannot read property 'store' of null
1:24:14 AM:   
1:24:14 AM:   - useSelector.js:103 
1:24:14 AM:     node_modules/react-redux/es/hooks/useSelector.js:103:1
1:24:14 AM:   
1:24:14 AM:   - index.js:12 
1:24:14 AM:     src/components/ProductListing/index.js:12:37
1:24:14 AM:   
1:24:14 AM: 
1:24:14 AM: not finished Generating image thumbnails - 85.375s
1:24:14 AM: ​
1:24:14 AM: ────────────────────────────────────────────────────────────────
1:24:14 AM:   "build.command" failed                                        

【问题讨论】:

    标签: reactjs webpack react-redux graphql gatsby


    【解决方案1】:

    大量缺乏细节和配置(gatsby-ssr.jsgatsby-browser.js 等)。但是,我认为您的问题与this GitHub thread 非常相似。所以:

    • 如果您使用的是gatsby-ssr.js API(特别是replaceRenderer)。尝试改变:

        exports.replaceRenderer
      

      收件人:

      export const replaceRenderer
      
    • 删除代码中的 connect 导入(来自 Redux)。如果不使用,应该避免这种情况:

      import { connect } from 'react-redux'
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 2019-08-03
      • 2016-11-24
      相关资源
      最近更新 更多