bvaughn/react-virtualized · error · Error

Required parameter "sortCallback" not specified

Error message

Required parameter "sortCallback" not specified

What it means

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.

Source

Thrown at source/Table/createMultiSort.js:42

  /**
   * Specifies the fields currently responsible for sorting data,
   * In order of importance.
   */
  sortBy: Array<string>,

  /**
   * Specifies the direction a specific field is being sorted in.
   */
  sortDirection: SortDirectionMap,
};

export default function createMultiSort(
  sortCallback: Function,
  {defaultSortBy, defaultSortDirection = {}}: MultiSortOptions = {},
): MultiSortReturn {
  if (!sortCallback) {
    throw Error(`Required parameter "sortCallback" not specified`);
  }

  const sortBy = defaultSortBy || [];
  const sortDirection = {};

  sortBy.forEach(dataKey => {
    sortDirection[dataKey] =
      defaultSortDirection[dataKey] !== undefined
        ? defaultSortDirection[dataKey]
        : 'ASC';
  });

  function sort({
    defaultSortDirection,
    event,
    sortBy: dataKey,
  }: SortParams): void {
    if (event.shiftKey) {

View on GitHub (pinned to c737715486)

Solutions

  1. Pass a sort callback as the first argument: createMultiSort(({sortBy, sortDirection}) => setSortState({sortBy, sortDirection})).
  2. If you use Table with default sort, pass createMultiSort(this._sort) where _sort updates state used by sortBy/sortDirection props.
  3. Check the argument order — options ({defaultSortBy, defaultSortDirection}) is the SECOND parameter, not the first.
  4. If sort behavior is unneeded, do not use createMultiSort at all; omit the onSort handler instead of passing an empty factory call.

Example fix

// before
const sortState = createMultiSort({defaultSortBy: ['name']});

// after
const sortState = createMultiSort(
  ({sortBy, sortDirection}) => this.setState({sortBy, sortDirection}),
  {defaultSortBy: ['name']}
);
Defensive patterns

Strategy: validation

Validate before calling

function safeCreateMultiSort(sortCallback, options) {
  if (typeof sortCallback !== 'function') {
    throw new TypeError('createMultiSort requires a sortCallback function as its first argument');
  }
  return createMultiSort(sortCallback, options);
}

Type guard

function isSortCallback(v) {
  return typeof v === 'function' && v.length <= 1;
}

Try / catch

try {
  const multiSort = createMultiSort(sortCallback, {defaultSortBy});
} catch (e) {
  if (String(e.message).includes('sortCallback')) {
    console.error('Table sort handler not wired: provide a sortCallback');
  } else {
    throw e;
  }
}

Prevention

When it happens

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

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


AI-assisted analysis of bvaughn/react-virtualized@c737715486 (2026-08-30). Data as JSON: /api/errors/4395f02ac9e9125b. Report an issue: GitHub.