necolas/react-native-web · warning

`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x:

Error message

`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.

What it means

ScrollView.scrollTo used to take positional (y, x, animated) arguments; it now expects a single {x, y, animated} object. Passing a number as the first argument logs this deprecation console.warn. Functionality still works but the legacy signature is deprecated.

Source

Thrown at packages/react-native-web/src/exports/ScrollView/index.js:516

  };

  /**
   * Scrolls to a given x, y offset, either immediately or with a smooth animation.
   * Syntax:
   *
   * scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
   *
   * Note: The weird argument signature is due to the fact that, for historical reasons,
   * the function also accepts separate arguments as as alternative to the options object.
   * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
   */
  scrollTo = (
    y?: number | { x?: number, y?: number, animated?: boolean },
    x?: number,
    animated?: boolean
  ) => {
    if (typeof y === 'number') {
      console.warn(
        '`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.'
      );
    } else {
      ({ x, y, animated } = y || emptyObject);
    }

    this.scrollResponderScrollTo({
      x: x || 0,
      y: y || 0,
      animated: animated !== false
    });
  };

  /**
   * If this is a vertical ScrollView scrolls to the bottom.
   * If this is a horizontal ScrollView scrolls to the right.
   *
   * Use `scrollToEnd({ animated: true })` for smooth animated scrolling,

View on GitHub (pinned to a9de220ba9)

Solutions

  1. Use the object form: ref.scrollTo({ x: 0, y: 500, animated: true }).
  2. Search codebase for scrollTo( with numeric first arg and migrate all call sites.
  3. Note the historical parameter order was (y, x) — double-check any converted values were not swapped.

Example fix

// before
ref.scrollTo(500, 0, true);
// after
ref.scrollTo({ x: 0, y: 500, animated: true });
Defensive patterns

Strategy: validation

Validate before calling

function safeScrollTo(ref, opts) {
  if (typeof opts === 'number') throw new TypeError('Use scrollTo({x, y, animated}), not legacy (y, x, animated)');
  ref.scrollTo(opts);
}

Type guard

const isScrollToOptions = (a) => a != null && typeof a === 'object' && ('x' in a || 'y' in a || 'animated' in a);

Try / catch

console.warn = ((orig) => (...a) => { if (/scrollTo\(y, x, animated\).*deprecated/.test(a[0])) throw new Error(a[0]); orig(...a); })(console.warn);

Prevention

When it happens

Trigger: Calling ref.scrollTo(0, 500, true) with numeric positional arguments.

Common situations: Legacy RN snippets where the argument order was (y, x, animated); older third-party scroll helpers; pre-codemod codebases.

Related errors


AI-assisted analysis of necolas/react-native-web@a9de220ba9 (2026-09-01). Data as JSON: /api/errors/4fbe1b6c4f9b2f34. Report an issue: GitHub.