connected-react-router icon indicating copy to clipboard operation
connected-react-router copied to clipboard

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

Open vchouhan opened this issue 5 years ago • 15 comments

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

vchouhan avatar Jan 20 '19 03:01 vchouhan

@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.

shieldo avatar Jan 21 '19 14:01 shieldo

Same here

cristian-sima avatar Feb 20 '19 18:02 cristian-sima

@vchouhan what font are you using?

cristian-sima avatar Feb 20 '19 18:02 cristian-sima

+1

MateuszDev96 avatar Mar 06 '19 21:03 MateuszDev96

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

Filipsi avatar Apr 04 '19 11:04 Filipsi

Same here!

reisdev avatar Apr 12 '19 12:04 reisdev

Same here.

hgs-fredarters avatar Apr 15 '19 21:04 hgs-fredarters

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

dagda1 avatar Apr 20 '19 23:04 dagda1

Same here.

ArseniySilin avatar Jun 10 '19 12:06 ArseniySilin

Same here.

draperunner avatar Jun 24 '19 08:06 draperunner

Same problem. Any updates yet? :(

BiosBoy avatar Aug 02 '19 14:08 BiosBoy

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! :)

BiosBoy avatar Aug 05 '19 09:08 BiosBoy

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')
);

RyanPWalker avatar Mar 19 '20 01:03 RyanPWalker

~~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.

crowmw avatar Mar 26 '20 09:03 crowmw

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

RyanPWalker avatar Mar 26 '20 18:03 RyanPWalker