Saya ingin rute seperti: /blog/:blogId/:slug

Saya mencoba ini di gatsby-node.js saya -

exports.onCreatePage = async ({ page, actions }) => {
  const { createPage } = actions

  createPage({
      path: "/blog/",
      matchPath: "/blog/:blogId/:slug",
      component: path.resolve("src/components/layouts/SingleBlogPageLayout.jsx"),
  })
}

Ini berfungsi dengan baik di gatsby develop tetapi menunjukkan masalah di gatsby build

Kesalahannya adalah:

failed Building static HTML for pages - 6.584s

 ERROR #95313 

Building static HTML failed for path "/"

See our docs page for more info on this error: https://gatsby.dev/debug-html


  247 | 
  248 | 
> 249 |       var store = didStoreComeFromProps ? props.store : contextValue.store;
      | ^
  250 |       var childPropsSelector = useMemo(function () {
  251 |         // The child props selector needs the store reference as an input.
  252 |         // Re-create this selector whenever the store changes.


  WebpackError: TypeError: Cannot read property 'store' of null

  - connectAdvanced.js:249 ConnectFunction
    node_modules/react-redux/es/components/connectAdvanced.js:249:1
3
Shawon Chy 23 Mei 2020, 08:44

1 menjawab

Jawaban Terbaik

Tambahkan pembungkus redux Anda di kedua file gatsby-browser.js& gatsby-ssr.js

Import wrapWithProvider from "./wrap-with-provider"

export const wrapRootElement = wrapWithProvider

Semoga ini berhasil

4
Md.Abdul Halim Rafi 23 Mei 2020, 07:20