reduxjs/react-redux · error

Could not find "store" in the context of "${displayName}". E

Error message

Could not find "store" in the context of "${displayName}". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to ${displayName} in connect options.

What it means

react-redux's connect() HOC obtains the Redux store either from props or from the React context set up by <Provider>. This error is thrown during rendering of the connected component when neither source supplies a store, meaning the component tree above the connected component has no <Provider> (or the custom context passed to connect options doesn't match the one <Provider> provides). The library throws explicitly (dev builds) because rendering without a store would otherwise fail with a confusing undefined error.

Source

Thrown at src/components/connect.tsx:763

      // Retrieve the store and ancestor subscription via context, if available
      const contextValue = React.useContext(ContextToUse)

      // The store _must_ exist as either a prop or in context.
      // We'll check to see if it _looks_ like a Redux store first.
      // This allows us to pass through a `store` prop that is just a plain value.
      const didStoreComeFromProps =
        Boolean(props.store) &&
        Boolean(props.store!.getState) &&
        Boolean(props.store!.dispatch)
      const didStoreComeFromContext =
        Boolean(contextValue) && Boolean(contextValue!.store)

      if (
        process.env.NODE_ENV !== 'production' &&
        !didStoreComeFromProps &&
        !didStoreComeFromContext
      ) {
        throw new Error(
          `Could not find "store" in the context of ` +
            `"${displayName}". Either wrap the root component in a <Provider>, ` +
            `or pass a custom React context provider to <Provider> and the corresponding ` +
            `React context consumer to ${displayName} in connect options.`,
        )
      }

      // Based on the previous check, one of these must be true
      const store: Store = didStoreComeFromProps
        ? props.store!
        : contextValue!.store

      const getServerState = didStoreComeFromContext
        ? contextValue!.getServerState
        : store.getState

      const childPropsSelector = React.useMemo(() => {
        // The child props selector needs the store reference as an input.

View on GitHub (pinned to 16f1a91eb2)

Solutions

  1. Wrap the component's root with <Provider store={store}> in app entry point (or in the test/story render helper).
  2. Ensure a single version of react-redux and react in node_modules (dedupe: npm/yarn/pnpm dedupe or resolutions).
  3. If using a custom context, pass the SAME context to both <Provider context={MyContext}> and the connect options: connect(mapState, null, null, {context: MyContext}).
  4. Pass the store directly as a prop: <ConnectedComponent store={store} /> (mainly for testing/store-subscription edge cases).
  5. Verify only one React renderer instance renders the component (no mismatched react-dom/react-native copies).

Example fix

// before
const store = createStore(reducer)
render(<App />) // App renders connected components -> throws

// after
import { Provider } from 'react-redux'
render(
  <Provider store={store}>
    <App />
  </Provider>
) // or in tests: render(<App />, {wrapper: ({children}) => <Provider store={store}>{children}</Provider>})
Defensive patterns

Strategy: validation

When it happens

Trigger: Rendering a connect()-wrapped component when: (1) no <Provider store={...}> exists above it in the tree; (2) two copies of react-redux are installed so the component reads a different React context than the Provider writes; (3) a custom context is passed to connect options (e.g. connect(mapStateToProps, null, null, {context: MyContext})) but <Provider> uses the default context or a different one; (4) multiple React renderers / duplicate react-dom copies cause context to not propagate; (5) the store prop was expected but not passed and no Provider exists.

Common situations: Testing a connected component with react-testing-library/enzyme without wrapping in a Provider; rendering a connected component in a story or isolated entry point; monorepo/duplicate node_modules causing context mismatch; forgetting Provider after refactoring to multiple React roots (e.g. portals into another root, React 18 createRoot trees); passing context to connect but forgetting the same context on Provider.

Related errors


AI-assisted analysis of reduxjs/react-redux@16f1a91eb2 (2026-08-31). Data as JSON: /api/errors/d54148c364bdc909. Report an issue: GitHub.