Skip to content

Could not find "store" error, the root is wrapped in a Provider #119

@julienvincent

Description

@julienvincent

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions