【发布时间】:2021-03-19 06:13:22
【问题描述】:
提供者没有将 store 发送到组件,我得到一个错误
Error: Could not find "store" in the context of "Connect(App)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(App) in connect options.
这是代码:
const store = createStore(reducer, window.__REDUX_DEVTOOLS_EXTENSION__ &&
window.__REDUX_DEVTOOLS_EXTENSION__()
);
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<App/>
</Provider>
</React.StrictMode>
,
document.getElementById('root')
);
【问题讨论】:
-
显示相关的导入,以及使用的 redux 和 react-redux 的版本,会有所帮助。
-
谢谢,我尝试使用“react-redux / lib / components / Provider”而不是“react-redux”导入Provider,它成功了。
标签: javascript node.js reactjs redux react-redux