{"record":{"id":"4395f02ac9e9125b","repo":"bvaughn/react-virtualized","slug":"required-parameter-sortcallback-not-specified","errorCode":null,"errorMessage":"Required parameter \"sortCallback\" not specified","messagePattern":"Required parameter \"sortCallback\" not specified","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/Table/createMultiSort.js","lineNumber":42,"sourceCode":"\n  /**\n   * Specifies the fields currently responsible for sorting data,\n   * In order of importance.\n   */\n  sortBy: Array<string>,\n\n  /**\n   * Specifies the direction a specific field is being sorted in.\n   */\n  sortDirection: SortDirectionMap,\n};\n\nexport default function createMultiSort(\n  sortCallback: Function,\n  {defaultSortBy, defaultSortDirection = {}}: MultiSortOptions = {},\n): MultiSortReturn {\n  if (!sortCallback) {\n    throw Error(`Required parameter \"sortCallback\" not specified`);\n  }\n\n  const sortBy = defaultSortBy || [];\n  const sortDirection = {};\n\n  sortBy.forEach(dataKey => {\n    sortDirection[dataKey] =\n      defaultSortDirection[dataKey] !== undefined\n        ? defaultSortDirection[dataKey]\n        : 'ASC';\n  });\n\n  function sort({\n    defaultSortDirection,\n    event,\n    sortBy: dataKey,\n  }: SortParams): void {\n    if (event.shiftKey) {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/bvaughn/react-virtualized/blob/c737715486f724586aee8870ebea1e9efb7b0bfe/source/Table/createMultiSort.js#L24-L60","documentation":"createMultiSort() builds the multi-column sort state handler used by react-virtualized's Table (defaultSortBy etc.). Its first argument, sortCallback, is the function invoked whenever the user sorts a column (typically ({sortBy, sortDirection}) => setSortBy(...)). Since without it sorting events could not be propagated, the factory throws immediately when the parameter is falsy.","triggerScenarios":"Calling createMultiSort() or createMultiSort(options) with no first argument, or passing null/undefined for sortCallback — e.g. misreading the signature as createMultiSort({defaultSortBy: [...]}) and putting the options object first.","commonSituations":"Wiring up Table's onSort manually with sortRenderer={createMultiSort()} forgetting the callback, refactoring a Table component and dropping the callback argument, or conditionally defining the callback so it arrives undefined.","solutions":["Pass a sort callback as the first argument: createMultiSort(({sortBy, sortDirection}) => setSortState({sortBy, sortDirection})).","If you use Table with default sort, pass createMultiSort(this._sort) where _sort updates state used by sortBy/sortDirection props.","Check the argument order — options ({defaultSortBy, defaultSortDirection}) is the SECOND parameter, not the first.","If sort behavior is unneeded, do not use createMultiSort at all; omit the onSort handler instead of passing an empty factory call."],"exampleFix":"// before\nconst sortState = createMultiSort({defaultSortBy: ['name']});\n\n// after\nconst sortState = createMultiSort(\n  ({sortBy, sortDirection}) => this.setState({sortBy, sortDirection}),\n  {defaultSortBy: ['name']}\n);","handlingStrategy":"validation","validationCode":"function safeCreateMultiSort(sortCallback, options) {\n  if (typeof sortCallback !== 'function') {\n    throw new TypeError('createMultiSort requires a sortCallback function as its first argument');\n  }\n  return createMultiSort(sortCallback, options);\n}","typeGuard":"function isSortCallback(v) {\n  return typeof v === 'function' && v.length <= 1;\n}","tryCatchPattern":"try {\n  const multiSort = createMultiSort(sortCallback, {defaultSortBy});\n} catch (e) {\n  if (String(e.message).includes('sortCallback')) {\n    console.error('Table sort handler not wired: provide a sortCallback');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Always pass the callback as the FIRST argument; options object is second","Type-check with Flow/TypeScript so createMultiSort(options) alone fails at compile time","Use the Table onSort={createMultiSort(this._sort)} pattern with a defined handler before render","Avoid conditionally defined callbacks that can be undefined at factory-call time"],"tags":["missing-parameter","api-misuse","table","sorting"],"backgroundTag":"missing-required-callback","analyzedSha":"c737715486f724586aee8870ebea1e9efb7b0bfe","analyzedAt":"2026-08-30T00:33:38.249Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}