{"record":{"id":"0634cbecbe078f6d","repo":"reduxjs/react-redux","slug":"invalid-value-of-type-typeof-arg-for-name-ar","errorCode":null,"errorMessage":"Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.","messagePattern":"Invalid value of type (.+?) for (.+?) argument when connecting component (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connect/invalidArgFactory.ts","lineNumber":8,"sourceCode":"import type { Action, Dispatch } from 'redux'\n\nexport function createInvalidArgFactory(arg: unknown, name: string) {\n  return (\n    dispatch: Dispatch<Action<string>>,\n    options: { readonly wrappedComponentName: string },\n  ) => {\n    throw new Error(\n      `Invalid value of type ${typeof arg} for ${name} argument when connecting component ${\n        options.wrappedComponentName\n      }.`,\n    )\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":15,"githubUrl":"https://github.com/reduxjs/react-redux/blob/16f1a91eb2cc3817bf63753e8c90e528a9f0580c/src/connect/invalidArgFactory.ts#L1-L15","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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 })"],"exampleFix":"// before\nconst C = connect(mapStateToProps, 'someString')(MyComponent)\n// after\nconst C = connect(mapStateToProps, mapDispatchToProps)(MyComponent)","handlingStrategy":"validation","validationCode":"function isConnectArg(v) {\n  return typeof v === 'function' || (v !== null && typeof v === 'object') || v == null;\n}\nif (!isConnectArg(mapStateToProps)) throw new TypeError('mapStateToProps must be a function, object, or undefined');","typeGuard":"function isMapDispatch(v: unknown): v is Record<string, (...a: any[]) => any> | ((...a: any[]) => any) | undefined {\n  return typeof v === 'function' || (v !== null && typeof v === 'object') || v === undefined;\n}","tryCatchPattern":"try {\n  const Connected = connect(mapState, mapDispatch)(Component)\n} catch (e) {\n  console.error('connect argument invalid:', e.message)\n  throw e // connect errors are programmer errors; fail fast\n}","preventionTips":["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"],"tags":["react-redux","connect","invalid-argument","runtime-error"],"backgroundTag":"connect-invalid-argument","analyzedSha":"16f1a91eb2cc3817bf63753e8c90e528a9f0580c","analyzedAt":"2026-08-31T22:28:37.628Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}