Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'store' of undefined #137

Open
CaptainOfFlyingDutchman opened this issue Jul 7, 2019 · 3 comments
Open

Cannot read property 'store' of undefined #137

CaptainOfFlyingDutchman opened this issue Jul 7, 2019 · 3 comments

Comments

@CaptainOfFlyingDutchman
Copy link

CaptainOfFlyingDutchman commented Jul 7, 2019

Hello,

I'm getting the following error at the time of SSR.

TypeError: Cannot read property 'store' of undefined
    at Object.children (/home/manvendra/Desktop/projects/my-app/node_modules/redux-connect/lib/components/AsyncConnect.js:160:35)

I'm using following version of packages
"react-redux": "7.1.0",
"redux-connect": "9.0.0",
"redux": "4.0.1",
"redux-actions": "2.6.5",
"react-router": "4.3.1",
"react-router-config": "4.4.0-beta.6",
"react-router-dom": "4.3.1",

I tried it with Router v5, but that has its own problem like can't call withRouter without a Router.

Could you please suggest what is the problem?

Here is my code also.

<Provider store={store} key="provider">
      <BrowserRouter>
          <ReduxAsyncConnect routes={routes} />
      </BrowserRouter>
</Provider>
<Provider store={store}>
     <StaticRouter context={context} location={location}>
          <ReduxAsyncConnect routes={routes} />
     </StaticRouter>
</Provider>

Here is the full stack trace for more clarity

TypeError: Cannot read property 'store' of undefined
    at Object.children (/home/manvendra/Desktop/projects/my-app/node_modules/redux-connect/lib/components/AsyncConnect.js:160:35)
    at e.children [as render] (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:58)
    at e.render [as read] (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:50)
    at read (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:74)
    at renderToString (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/server/Document.js:56:19)
    at f (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:498)
    at c (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:1)
    at e.Sa [as render] (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:465)
    at e.render [as read] (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:50)
    at read (/home/manvendra/Desktop/projects/my-app/assets/server/webpack:/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:74)
@CaptainOfFlyingDutchman
Copy link
Author

CaptainOfFlyingDutchman commented Jul 13, 2019

If I change

'process.env.NODE_ENV': JSON.stringify('production') to 'process.env.NODE_ENV': JSON.stringify('development')

inside webpack.DefinePlugin then it works. I think it has some problem with production environment.

This is my babel packages list

"@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-proposal-decorators": "7.4.4",
"@babel/plugin-proposal-object-rest-spread": "7.4.4",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-transform-object-assign": "7.2.0",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",

@CaptainOfFlyingDutchman
Copy link
Author

@AVVS please help.

@gmixo
Copy link

gmixo commented Sep 12, 2019

Having the same issue with dev mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants