Store not available in props/context of components rendered using react-router
See original GitHub issueWhat I am rendering:
<Provider store={store}>
<Router history={hashHistory}>
<Route path='/' component={App}>
<IndexRoute component={HomePage} onEnter={_ensureLoggedIn}/>
<Route path="login" component={ SessionForm }/>
</Route>
</Router>
</Provider>
when attempting a sign in I am getting ‘Cannot read property ‘dispatch’ of undefined’ when calling this.context.store.dispatch
I threw a debugger and store is not present on this.props or this.context (SessionForm component).
I thought I tried everything from all the documentation on this subject I could find, still no help though
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why is React Router location props only available in Context?
While rendering a component using render props method you need get the router props as an argument in the callback function.
Read more >How to protect your routes with React Context - Medium
We're going to take a look at how it works by building a protected route component. Context is about encapsulating state…
Read more >location - React Router: Declarative Routing for React.js
The router will provide you with a location object in a few places: Route component as this.props.location; Route render as ({ location })...
Read more >Provider | React Redux
Could not find "store" in the context of "Connect(MyComponent)". Either wrap the root component in a <Provider> , or pass a custom React...
Read more >Passing Data Deeply with Context - React Docs
Context is not limited to static values. If you pass a different value on the next render, React will update all the components...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Excellent thank you Tim! and apologies for totally missing that part of the readme, I believed this particular functionality worked independently from connect
Yes, but that’s removing a big benefit of having this library. You should use
@connect
instead like so: https://github.com/reactjs/react-redux/blob/master/docs/api.md#inject-todos-and-all-action-creators-addtodo-completetodo--as-actions