“Could not find ”store“ in either the context or props” I'm getting this error while trying simple react-redux code

前端 未结 1 1378
礼貌的吻别
礼貌的吻别 2021-01-26 05:05

This is my booklist container

import React, {Component} from \'react\';
import { connect } from \'react-redux\';


class BookList extends Component{
  renderList         


        
相关标签:
1条回答
  • 2021-01-26 05:22

    Create a store and enclose your components within a Provider like

    import {createStore} from 'redux';
    import { Provider } from 'react-redux'
    import RootReducer form '/path/to/rootreducer';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import App from './components/app';
    import './index.css';
    const store = createStore(RootReducer);
    
    ReactDOM.render(
       <Provider store={store}>
           <App />
       </Provider>,
      document.getElementById('root')
    );
    
    0 讨论(0)
提交回复
热议问题