I have this error :
Uncaught Invariant Violation: Could not find "store" in either the context or props of "Connect(ItemIndex)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(ItemIndex)".
My code is :
const createStoreWithMiddleware = applyMiddleware(
promise
)(createStore);
ReactDOM.render(<ItemIndex />, document.querySelector('.container'));
How to resolve this error?
It doesn't work because your action creator is just a function that returns an action. It is up to you to actually dispatch it. We can't bind your action creators to a particular Store instance during the definition because apps that render on the server need a separate Redux store for every request.
Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider> If you need to access redux store in App component, you should wrap the App component with <Provider /> , so that it can provide the react-redux context values to App and other nested components.
import {render, screen} from "@testing-library/react"; import {Provider} from "react-redux"; import {createStore} from "../../app/store"; import {Counter} from "./Counter"; describe('Counter component', () => { test('renders the counter component', () => { render( <Provider store={createStore()}> <Counter /> </Provider ...
I forgot to add the provider
import { Provider } from 'react-redux';
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<ItemIndex />
</Provider>
, document.querySelector('.container'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With