reduxjs/react-redux · error

Invalid value of type ${typeof arg} for ${name} argument whe

Error message

Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.

What it means

connect's first three arguments (mapStateToProps, mapDispatchToProps, mergeProps) must each be a function, an object, or undefined/null. When a value of any other type is passed, react-redux returns this factory that immediately throws at connect time, naming the offending argument and the wrapped component.

Source

Thrown at src/connect/invalidArgFactory.ts:8

import type { Action, Dispatch } from 'redux'

export function createInvalidArgFactory(arg: unknown, name: string) {
  return (
    dispatch: Dispatch<Action<string>>,
    options: { readonly wrappedComponentName: string },
  ) => {
    throw new Error(
      `Invalid value of type ${typeof arg} for ${name} argument when connecting component ${
        options.wrappedComponentName
      }.`,
    )
  }
}

View on GitHub (pinned to 16f1a91eb2)

Solutions

  1. Check the argument in the named slot of the connect() call and ensure it is a function, an object of action creators, or undefined/null
  2. Verify imports: a default/named import that resolves to the wrong module export is the most common cause
  3. Pass connect options as the 4th argument: connect(mapState, mapDispatch, null, { forwardRef: true })

Example fix

// before
const C = connect(mapStateToProps, 'someString')(MyComponent)
// after
const C = connect(mapStateToProps, mapDispatchToProps)(MyComponent)
Defensive patterns

Strategy: validation

Validate before calling

function isConnectArg(v) {
  return typeof v === 'function' || (v !== null && typeof v === 'object') || v == null;
}
if (!isConnectArg(mapStateToProps)) throw new TypeError('mapStateToProps must be a function, object, or undefined');

Type guard

function isMapDispatch(v: unknown): v is Record<string, (...a: any[]) => any> | ((...a: any[]) => any) | undefined {
  return typeof v === 'function' || (v !== null && typeof v === 'object') || v === undefined;
}

Try / catch

try {
  const Connected = connect(mapState, mapDispatch)(Component)
} catch (e) {
  console.error('connect argument invalid:', e.message)
  throw e // connect errors are programmer errors; fail fast
}

Prevention

When it happens

Trigger: Calling connect() with e.g. a boolean, number, or string as mapStateToProps/mapDispatchToProps/mergeProps — typically the result of a bad import (undefined vs. wrong value), a typo passing the wrong variable, or calling connect(validMapState, 'store') instead of passing options as the fourth argument.

Common situations: Circular imports leaving a factory as an unexpected value, copy-pasted connect calls where an options object was shifted into the mergeProps slot, or passing a plain non-object constant from misconfigured HOC helpers.

Related errors


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