-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
I'm structuring my project almost exactly like the real-world redux example, and have wrapped my react-router in a Provider with the store specified, but after trying to apply connect() to a component I get the error:
Uncaught Error: Invariant Violation: Could not find "store" in either the context or props of "Connect(Home)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(Home)".
render
import { render, createFactory } from 'react'
import { Provider } from 'react-redux';
import router from './router/router'
import store from './flux/store'
window.onload = () => {
render(createFactory(Provider)({store: store},
() => router
), document.body)
};Router
import { _ } from 'factories'
import { Router, IndexRoute, Route } from 'react-router'
import history from 'history/lib/createBrowserHistory'
import Home from '../components/home/home'
let route = _(Route),
index = _(IndexRoute);
let router = _(Router)({history: history()},
route({path: 'home', component: Home})
);
export default router;Component
import React, { PropTypes } from 'react'
import { div } from 'factories'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux';
import * as users from '../../flux/actions/users'
class Home extends React.Component {
constructor() {
super();
this.state = {}
}
render() {
return (
div({})
)
}
}
export default connect(
state => {
return {
users: state.users
}
},
dispatch => bindActionCreators(users, dispatch)
)(Home)Metadata
Metadata
Assignees
Labels
No labels