{"record":{"id":"d54148c364bdc909","repo":"reduxjs/react-redux","slug":"could-not-find-store-in-the-context-of-displa","errorCode":null,"errorMessage":"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.","messagePattern":"Could not find \"store\" in the context of \"(.+?)\"\\. Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to (.+?) in connect options\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/connect.tsx","lineNumber":763,"sourceCode":"      // Retrieve the store and ancestor subscription via context, if available\n      const contextValue = React.useContext(ContextToUse)\n\n      // The store _must_ exist as either a prop or in context.\n      // We'll check to see if it _looks_ like a Redux store first.\n      // This allows us to pass through a `store` prop that is just a plain value.\n      const didStoreComeFromProps =\n        Boolean(props.store) &&\n        Boolean(props.store!.getState) &&\n        Boolean(props.store!.dispatch)\n      const didStoreComeFromContext =\n        Boolean(contextValue) && Boolean(contextValue!.store)\n\n      if (\n        process.env.NODE_ENV !== 'production' &&\n        !didStoreComeFromProps &&\n        !didStoreComeFromContext\n      ) {\n        throw new Error(\n          `Could not find \"store\" in the context of ` +\n            `\"${displayName}\". Either wrap the root component in a <Provider>, ` +\n            `or pass a custom React context provider to <Provider> and the corresponding ` +\n            `React context consumer to ${displayName} in connect options.`,\n        )\n      }\n\n      // Based on the previous check, one of these must be true\n      const store: Store = didStoreComeFromProps\n        ? props.store!\n        : contextValue!.store\n\n      const getServerState = didStoreComeFromContext\n        ? contextValue!.getServerState\n        : store.getState\n\n      const childPropsSelector = React.useMemo(() => {\n        // The child props selector needs the store reference as an input.","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/reduxjs/react-redux/blob/16f1a91eb2cc3817bf63753e8c90e528a9f0580c/src/components/connect.tsx#L745-L781","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wrap the component's root with <Provider store={store}> in app entry point (or in the test/story render helper).","Ensure a single version of react-redux and react in node_modules (dedupe: npm/yarn/pnpm dedupe or resolutions).","If using a custom context, pass the SAME context to both <Provider context={MyContext}> and the connect options: connect(mapState, null, null, {context: MyContext}).","Pass the store directly as a prop: <ConnectedComponent store={store} /> (mainly for testing/store-subscription edge cases).","Verify only one React renderer instance renders the component (no mismatched react-dom/react-native copies)."],"exampleFix":"// before\nconst store = createStore(reducer)\nrender(<App />) // App renders connected components -> throws\n\n// after\nimport { Provider } from 'react-redux'\nrender(\n  <Provider store={store}>\n    <App />\n  </Provider>\n) // or in tests: render(<App />, {wrapper: ({children}) => <Provider store={store}>{children}</Provider>})","handlingStrategy":"validation","validationCode":"","typeGuard":"","tryCatchPattern":"","preventionTips":[],"tags":["react-redux","redux","react-context","provider","store","setup"],"backgroundTag":"missing-redux-provider","analyzedSha":"16f1a91eb2cc3817bf63753e8c90e528a9f0580c","analyzedAt":"2026-08-31T22:28:37.628Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}