reduxjs/react-redux · error

Unexpected value for

Error message

Unexpected value for ${methodName} in connect.

What it means

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.

Solutions

  1. Log the selector just before connect() to confirm it is defined and truthy
  2. Break circular imports: move the selector into its own module that does not import back into the component file
  3. For object-form mapState/mapDispatch, ensure the object literal (not undefined) is passed

Example fix

// before (circular import leaves selector undefined)
import { mapStateToProps } from './selectors'
export default connect(mapStateToProps)(Comp)
// after
import { mapStateToProps } from './pureSelectors' // no cycle
export default connect(mapStateToProps)(Comp)
Defensive patterns

Strategy: validation

Validate before calling

if (!mapStateToProps) throw new Error('connect: mapStateToProps is falsy (undefined import or circular dependency?)');
if (typeof mapStateToProps === 'object' && !('dependsOnOwnProps' in mapStateToProps)) {
  mapStateToProps.dependsOnOwnProps = false;
}

Type guard

function isSelector(v: unknown): v is ((state: any, ownProps?: any) => any) {
  return typeof v === 'function';
}

Try / catch

try {
  Connected = connect(mapStateToProps, mapDispatchToProps)(Component)
} catch (e) {
  if (e.message.includes('Unexpected value for')) {
    console.error('Selector undefined — check for circular imports')
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

Thrown at src/connect/verifySubselectors.ts:5

import warning from '../utils/warning'

function verify(selector: unknown, methodName: string): void {
  if (!selector) {
    throw new Error(`Unexpected value for ${methodName} in connect.`)
  } else if (
    methodName === 'mapStateToProps' ||
    methodName === 'mapDispatchToProps'
  ) {
    if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
      warning(
        `The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`,
      )
    }
  }
}

export default function verifySubselectors(
  mapStateToProps: unknown,
  mapDispatchToProps: unknown,
  mergeProps: unknown,
): void {
  verify(mapStateToProps, 'mapStateToProps')

View on GitHub (pinned to 16f1a91eb2)