Javascript TypeError:_this.store.getState在使用从Redux连接时不是函数

Javascript TypeError:_this.store.getState在使用从Redux连接时不是函数,javascript,node.js,reactjs,redux,react-redux,Javascript,Node.js,Reactjs,Redux,React Redux,当我第一次使用node app.js运行服务器时,一切正常,我收听了5050。然后我转到localhost:5050/并在服务器运行的控制台中收到这些警告 Warning: Failed propType: Required prop `store.subscribe` was not specified in `Provider`. Warning: Failed Context Types: Required child context `store.subscribe` was not s

当我第一次使用
node app.js运行服务器时,一切正常,我收听了5050
。然后我转到localhost:5050/并在服务器运行的控制台中收到这些警告

Warning: Failed propType: Required prop `store.subscribe` was not specified in `Provider`.
Warning: Failed Context Types: Required child context `store.subscribe` was not specified in `Provider`. 
该组件在那里呈现良好,但一旦我转到localhost:5050/ballerviews,我就会在服务器上看到它

TypeError: _this.store.getState is not a function
    at new Connect (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react-redux/lib/components/connect.js:133:38)
    at [object Object].ReactCompositeComponentMixin.mountComponent (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactCompositeComponent.js:148:18)
    at [object Object].wrapper [as mountComponent] (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactPerf.js:66:21)
    at Object.ReactReconciler.mountComponent (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactReconciler.js:37:35)
    at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactMultiChild.js:241:44)
    at ReactDOMComponent.Mixin._createContentMarkup (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactDOMComponent.js:591:32)
    at ReactDOMComponent.Mixin.mountComponent (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactDOMComponent.js:479:29)
    at Object.ReactReconciler.mountComponent (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactReconciler.js:37:35)
    at [object Object].ReactCompositeComponentMixin.mountComponent (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactCompositeComponent.js:225:34)
    at [object Object].wrapper [as mountComponent] (/Users/freddiecabrera/Desktop/ullibol-client/node_modules/react/lib/ReactPerf.js:66:21)
你可以在我的网站上查看完整的项目,因为我觉得通过在那里查看,你可以得到最好的理解


我今天一整天都在试图弄明白这一点,但我做不到。在我尝试在服务器上渲染之前,它工作得很好。我感谢你的帮助,如果你需要更多的信息来回答这个问题,请告诉我

只有两个小问题:

1.ES2015模块->CommonJS 您正在
src/store.js
中使用ES2015
export default
,但随后您需要通过上的
app.js
中的CommonJS使用它

这当然可以,但是在需要时,您需要访问默认属性。更新该行,如下所示:

//旧的
const store=require('./src/store.js')
//新的
const store=require('./src/store.js')。默认值
2.在服务器上调用
文档
src/components/BallerViews.jsx的第页,您正在访问服务器上不存在的文档。快速修复方法是将该行包装成一个条件:

//旧的
document.body.style.backgroundColor='#0e0e13'
//新的
如果(文档类型!==“未定义”){
document.body.style.backgroundColor='#0e0e13'
}

只有两个小问题:

1.ES2015模块->CommonJS 您正在
src/store.js
中使用ES2015
export default
,但随后您需要通过上的
app.js
中的CommonJS使用它

这当然可以,但是在需要时,您需要访问默认属性。更新该行,如下所示:

//旧的
const store=require('./src/store.js')
//新的
const store=require('./src/store.js')。默认值
2.在服务器上调用
文档
src/components/BallerViews.jsx的第页,您正在访问服务器上不存在的文档。快速修复方法是将该行包装成一个条件:

//旧的
document.body.style.backgroundColor='#0e0e13'
//新的
如果(文档类型!==“未定义”){
document.body.style.backgroundColor='#0e0e13'
}

该死!非常感谢你,你救了我,我真的很感谢你的帮助。因此,基本上,每当我想要访问文档或窗口时,我都必须将其包装在条件中?@FreddieCabrera是的,但只有在服务器渲染时。节点不了解DOM。一种流行的做法是使用诸如
\uuuu客户机\uuuuu
\uuuu服务器\uuuuuu
之类的全局对象,这样您就可以轻松地针对每个对象。您可以在服务器入口点(app.js)和Web包配置中执行此操作。我已经创建了一个要点来向您展示如何设置它:@MichaelLaCroix.default也为我修复了这个问题。很难遵循最佳实践,因为有太多的例子混合了ES2015和legacy。该死!非常感谢你,你救了我,我真的很感谢你的帮助。因此,基本上,每当我想要访问文档或窗口时,我都必须将其包装在条件中?@FreddieCabrera是的,但只有在服务器渲染时。节点不了解DOM。一种流行的做法是使用诸如
\uuuu客户机\uuuuu
\uuuu服务器\uuuuuu
之类的全局对象,这样您就可以轻松地针对每个对象。您可以在服务器入口点(app.js)和Web包配置中执行此操作。我已经创建了一个要点来向您展示如何设置它:@MichaelLaCroix.default也为我修复了这个问题。很难遵循最佳实践,因为有太多的示例混合了ES2015和legacy。