我想要一条类似/blog/:blogId/:slug
我在gatsby-node.js
-
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions
createPage({
path: "/blog/",
matchPath: "/blog/:blogId/:slug",
component: path.resolve("src/components/layouts/SingleBlogPageLayout.jsx"),
})
}
它在gatsby develop
中可以正常工作,但在gatsby build
中显示问题
错误是:
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
答案 0 :(得分:3)
在gatsby-browser.js
和gatsby-ssr.js
文件中添加redux包装器
Import wrapWithProvider from "./wrap-with-provider"
export const wrapRootElement = wrapWithProvider
希望这行得通