{"record":{"id":"27efd50062c6d3e4","repo":"reduxjs/react-redux","slug":"unexpected-value-for-methodname-in-connect","errorCode":null,"errorMessage":"Unexpected value for ${methodName} in connect.","messagePattern":"Unexpected value for (.+?) in connect\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connect/verifySubselectors.ts","lineNumber":5,"sourceCode":"import warning from '../utils/warning'\n\nfunction verify(selector: unknown, methodName: string): void {\n  if (!selector) {\n    throw new Error(`Unexpected value for ${methodName} in connect.`)\n  } else if (\n    methodName === 'mapStateToProps' ||\n    methodName === 'mapDispatchToProps'\n  ) {\n    if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {\n      warning(\n        `The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`,\n      )\n    }\n  }\n}\n\nexport default function verifySubselectors(\n  mapStateToProps: unknown,\n  mapDispatchToProps: unknown,\n  mergeProps: unknown,\n): void {\n  verify(mapStateToProps, 'mapStateToProps')","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/reduxjs/react-redux/blob/16f1a91eb2cc3817bf63753e8c90e528a9f0580c/src/connect/verifySubselectors.ts#L1-L23","documentation":"Before connect builds its selectors, verifySubselectors checks that mapState/mapDispatch selectors are truthy and, if they are objects (impure form), that they declare a dependsOnOwnProps property. A falsy selector means connect cannot compute props, so it throws immediately during connect setup.","triggerScenarios":"Passing undefined/null/false as mapStateToProps or mapDispatchToProps to connect(), e.g. when a module's export failed to initialize (circular import) or when a helper that was supposed to generate the selector returned undefined.","commonSituations":"Circular dependency where mapState is undefined at module-eval time, conditional export logic that skips the selector, or refactoring that deleted the selector but left connect(mapState, ...) in place.","solutions":["Log the selector just before connect() to confirm it is defined and truthy","Break circular imports: move the selector into its own module that does not import back into the component file","For object-form mapState/mapDispatch, ensure the object literal (not undefined) is passed"],"exampleFix":"// before (circular import leaves selector undefined)\nimport { mapStateToProps } from './selectors'\nexport default connect(mapStateToProps)(Comp)\n// after\nimport { mapStateToProps } from './pureSelectors' // no cycle\nexport default connect(mapStateToProps)(Comp)","handlingStrategy":"validation","validationCode":"if (!mapStateToProps) throw new Error('connect: mapStateToProps is falsy (undefined import or circular dependency?)');\nif (typeof mapStateToProps === 'object' && !('dependsOnOwnProps' in mapStateToProps)) {\n  mapStateToProps.dependsOnOwnProps = false;\n}","typeGuard":"function isSelector(v: unknown): v is ((state: any, ownProps?: any) => any) {\n  return typeof v === 'function';\n}","tryCatchPattern":"try {\n  Connected = connect(mapStateToProps, mapDispatchToProps)(Component)\n} catch (e) {\n  if (e.message.includes('Unexpected value for')) {\n    console.error('Selector undefined — check for circular imports')\n  }\n  throw e\n}","preventionTips":["Keep selectors in modules with no imports back into component files to avoid cycles","Run a build-time lint that flags falsy identifiers passed to connect","Prefer function-form mapStateToProps/mapDispatchToProps"],"tags":["react-redux","connect","selector","undefined"],"backgroundTag":"connect-invalid-argument","analyzedSha":"16f1a91eb2cc3817bf63753e8c90e528a9f0580c","analyzedAt":"2026-08-31T22:28:37.628Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}