connect cannot find store in either the context or props

风流意气都作罢 提交于 2019-12-11 10:36:06

问题


Recently tried adding redux to one of the apps. One of the solutions is to have root component wrapped within Provider. Did this, but still seeing below issue (in the browser). [Pasted only potentially relevant code from files].

Uncaught Error: Could not find "store" in either the context or props of "Connect(Gallery)". Either wrap the root component in a , or explicitly pass "store" as a prop to "Connect(Gallery)".

client/main.js

document.addEventListener('DOMContentLoaded', function() {
  ReactDOM.render(
     <Provider store={store}>
        <App/>
     </Provider>,
    document.getElementById('mount')
  );
});

shared/App./js

class App extends React.Component {

  render() {

    return (
      <BrowserRouter history={ browserHistory }>
        <div>
          <Route exact path="/" component={Gallery} />
          <Route path="/viewitem/:id" component={ViewItem} />
        </div>
      </BrowserRouter>
    );
  }

}

shared/redux/index.js

export const reducers = combineReducers({  
   images: imageReducer,
});

export function configureStore(initialState = {}) {  
  const store = createStore(
    reducers,
    initialState,
    applyMiddleware(...middleWare)
  )
  return store;
};

export const store = configureStore();

Could it be that BrowserRouter might not work with redux?

来源:https://stackoverflow.com/questions/46027360/connect-cannot-find-store-in-either-the-context-or-props

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!