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
- 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
- Verify imports: a default/named import that resolves to the wrong module export is the most common cause
- 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
- Type connect arguments with TypeScript (TypedConnect / Connect<...>) to catch wrong types at compile time
- Always pass connect options as the 4th argument, never shift them into mergeProps
- Beware circular imports for selectors/dispatch maps; keep them in leaf modules
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
- Unexpected value for ${methodName} in connect.
- You must pass a component to the function returned by connec
- You must pass a valid React context consumer as `props.conte
- could not find react-redux context value; please ensure the
- You must pass a selector to useSelector
AI-assisted analysis of reduxjs/react-redux@16f1a91eb2 (2026-08-31).
Data as JSON: /api/errors/0634cbecbe078f6d.
Report an issue: GitHub.