【问题标题】:React-Redux Provider not working for me. How i solve this problem?React-Redux Provider 不适合我。我如何解决这个问题?
【发布时间】: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


【解决方案1】:
猜你喜欢
  • 2020-11-11
  • 2022-06-14
  • 2019-10-14
  • 2020-03-25
  • 2020-02-14
  • 2020-07-30
  • 1970-01-01
相关资源
最近更新 更多