supasate / connected-react-router

A Redux binding for React Router v4
MIT License
4.73k stars 593 forks source link

Error `Could not find "store" in the context` when adding context to the provider and connectedRouter #241

Open vchouhan opened 5 years ago

vchouhan commented 5 years ago

Based on the migration to v5 and v6 and with the following code I'm getting the error listed below.

error message on application start Could not find "store" in the context of "Connect(Home)". 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(Home) in connect options.

Packages: "connected-react-router": "^6.2.1", "react-redux": "^6.0.0"

image
shieldo commented 5 years ago

@vchouhan Just a check: did you restart your app after bumping your local package? I'd been getting the same error until I remembered I still needed to do that.

cristian-sima commented 5 years ago

Same here

cristian-sima commented 5 years ago

@vchouhan what font are you using?

MateuszDev96 commented 5 years ago

+1

Filipsi commented 5 years ago

I am also having this problem, any updates on this?

reisdev commented 5 years ago

Same here!

hgs-fredarters commented 5 years ago

Same here.

dagda1 commented 5 years ago

i have this problem with an ssr react project. i saw another problem where the props apppeared to be replaced altogether with the router props

ArseniySilin commented 5 years ago

Same here.

draperunner commented 5 years ago

Same here.

BiosBoy commented 5 years ago

Same problem. Any updates yet? :(

BiosBoy commented 5 years ago

I've solved it via bumping up to date all the packages linked with connected-react-router directly: connected-react-router react redux react-redux react-router react-router-dom

Seems like some of the inner dependencies had a problem with new connected-react-router context core.

And it works for me now! :)

RyanPWalker commented 4 years ago

Figured it out. All I was missing was the ReactReduxContext

import { Provider, ReactReduxContext } from 'react-redux';

render(
    <Provider store={store}>
        <ConnectedRouter history={history} context={ReactReduxContext}>
            <App />
        </ConnectedRouter>
    </Provider>,
    document.getElementById('root')
);
crowmw commented 4 years ago

~~Same here @RyanPWalker and @BiosBoy does not help~~

@RyanPWalker I'm sorry

In my case, the problem concerned an outdated MaterialUI component that was creating Popovers outside the context. Changing the Popovers solved the problem.

RyanPWalker commented 4 years ago

@crowmw Why the thumbs down? It's still a valid solution, just not for your exact case.