usablica/intro.js · error

Provided callback for onskip was not a function.

Error message

Provided callback for onskip was not a function.

What it means

Tour class onSkip registers the callback fired when the user skips the tour (via the skip button), stored in this.callbacks.skip. It throws when isFunction(callback) is false, matching the library-wide guard on callback registration methods.

Source

Thrown at src/packages/tour/tour.ts:642

    this.callbacks.exit = callback;
    return this;
  }

  /**
   * @deprecated onskip is deprecated, please use onSkip instead.
   */
  onskip(callback: introSkipCallback) {
    return this.onSkip(callback);
  }

  /**
   * Add a callback to be called when the tour is skipped
   * @param {Function} callback callback function to be called
   */
  onSkip(callback: introSkipCallback) {
    if (!isFunction(callback)) {
      throw new Error("Provided callback for onskip was not a function.");
    }

    this.callbacks.skip = callback;
    return this;
  }

  /**
   * @deprecated onbeforeexit is deprecated, please use onBeforeExit instead.
   */
  onbeforeexit(callback: introBeforeExitCallback) {
    return this.onBeforeExit(callback);
  }

  /**
   * Add a callback to be called before the tour is exited
   * @param {Function} callback callback function to be called
   */
  onBeforeExit(callback: introBeforeExitCallback) {

View on GitHub (pinned to e5517e6a24)

Solutions

  1. Pass a function: introJs().onSkip(function(){ ... }).
  2. Fix the argument source: correct the config key/variable so it resolves to a function.
  3. Wrap non-function integrations: introJs().onSkip(() => analytics.track('skip')).
  4. Default optional handlers with a no-op function.
  5. Type-check before registering to avoid the throw entirely.

Example fix

// before
introJs().onSkip(analytics.track); // if track is undefined at this point
// after
introJs().onSkip(() => analytics.track('tour_skipped'));
Defensive patterns

Strategy: validation

Validate before calling

if (typeof skipCb !== 'function') { throw new TypeError('onSkip expects a function, got ' + typeof skipCb); }
introJs().onSkip(skipCb);

Type guard

function isFn(v: unknown): v is () => void { return typeof v === 'function'; }

Try / catch

try {
  tour.onSkip(cb);
} catch (e) {
  if (e.message.includes('onskip was not a function')) {
    tour.onSkip(() => {});
  } else { throw e; }
}

Prevention

When it happens

Trigger: introJs().onSkip() or onSkip(nonFunction) — e.g., an analytics tracker string, a Promise, or an undefined config value.

Common situations: Passing an analytics library object hoping it will be invoked; optional telemetry callbacks that are conditionally configured; copy-paste from onExit wiring with a stale variable.

Related errors


AI-assisted analysis of usablica/intro.js@e5517e6a24 (2026-08-31). Data as JSON: /api/errors/890f5f0c730be44c. Report an issue: GitHub.