question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error during build: `WebpackError: Could not find "store"`

See original GitHub issue

Description

I use redux to add a global state to my gatsby website. It works but the build failed:

WebpackError: Could not find "store" in either the context or props of "Connect(DefaulLayout)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(DefaulLayout)".

Environment

Gatsby version: 1.9.127 Node.js version: 9.2.0 Operating System: Ubuntu 17.10

File contents

I took this 2 files from https://github.com/gatsbyjs/gatsby/tree/master/examples/using-redux:

  • gatsby-browser.js:
import React from 'react'
import { Router } from 'react-router-dom'
import { Provider } from 'react-redux'

import createStore from './src/state/createStore'

exports.replaceRouterComponent = ({ history }) => {
  const store = createStore()

  const ConnectedRouterWrapper = ({ children }) => (
    <Provider store={store}>
      <Router history={history}>{children}</Router>
    </Provider>
  )

  return ConnectedRouterWrapper
}
  • gatsby-ssr.js:
import React from 'react'
import { Provider } from 'react-redux'
import { renderToString } from 'react-dom/server'

import createStore from './src/state/createStore'

exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
  const store = createStore()

  const ConnectedBody = () => (
    <Provider store={store}>
      {bodyComponent}
    </Provider>
  )

  replaceBodyHTMLString(renderToString(<ConnectedBody/>))
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
m-allansoncommented, Dec 16, 2017

Ohh ok I think gatsby-plugin-glamor means you’re running in to #2005. Thanks for creating the example repo 😃

Until there’s a better way of handling this, you’ll probably need to manually reimplement the gatsby-plugin-glamor code in your gatsby-ssr.js. Check out the examples in the linked issue.

1reaction
KyleAMathewscommented, Dec 16, 2017

Hmm yeah, really need to add the check described in #2005

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Could not find "store" in the context of "Connect(App)".
During the npm test, I get the following error: FAIL src/App.test.js × renders App (74 ms). ○ renders App **Could not find "store"...
Read more >
Troubleshooting Common Errors - Gatsby
If you see errors about not being able to find a resource in the cache it may be enough to clear your cache...
Read more >
[Support Guide] Netlify app builds locally but fails on deploy ...
Netlify build failed with webpack error - css-syntax-error (unknown word) ... Project builds locally but get "WebpackError: TypeError: Cannot read property ...
Read more >
[Solved]-Syntax in crac-webpack-rewired to solve webpack polyfills ...
[Solved]-Syntax in crac-webpack-rewired to solve webpack polyfills error-Reactjs ... loading is complete · Could not find "store" in the context of "Connect ...
Read more >
Changelog - Cypress Documentation
Fixed a regression introduced in Cypress 12 where cy.get() would ignore a null ... rejection would display an incomplete error message in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found