Could not find "store" in either the context or props of "Connect(ReactPlanner)"
Closed this issue · 2 comments
JaccoGoris commented
When using the React-planner as a dependency in a CRA, I got the following issue
Could not find "store" in either the context or props of "Connect(ReactPlanner)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(ReactPlanner)".
even though I've set up the planner exactly like the demo in the readme:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import * as serviceWorker from './serviceWorker';
import { Map } from 'immutable';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import {
Models as PlannerModels,
reducer as PlannerReducer,
ReactPlanner,
Plugins as PlannerPlugins
} from 'react-planner';
import MyCatalog from './demo/catalog/mycatalog';
//define state
let AppState = Map({
'react-planner': new PlannerModels.State()
});
//define reducer
let reducer = (state, action) => {
state = state || AppState;
state = state.update('react-planner', plannerState =>
PlannerReducer(plannerState, action)
);
return state;
};
let store = createStore(
reducer,
null,
window.devToolsExtension ? window.devToolsExtension() : f => f
);
let plugins = [
PlannerPlugins.Keyboard(),
PlannerPlugins.Autosave('react-planner_v0'),
PlannerPlugins.ConsoleDebugger()
];
ReactDOM.render(
<Provider store={store}>
<ReactPlanner
catalog={MyCatalog}
width={800}
height={600}
plugins={plugins}
stateExtractor={state => state.get('react-planner')}
/>
</Provider>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
am I missing something?
JaccoGoris commented
This was the result of a mismatch between redux versions. my consuming project was using react-redux 6 and the planner is on 5. downgrading to 5 fixed it! :)
rfarren01 commented
Did you ever go about updating your redux to ^6 @JaccoGoris ?
We stumbled across the same error today and having difficulty getting syncd to consuming project