necolas/react-native-web · warning

message

Error message

message

What it means

warnOnce is a dev-only helper that prints a console.warn for a given key exactly once per session, then records the key in warnedKeys to suppress repeats. The literal message string 'message' appears when a caller passes a placeholder or wrong argument — i.e. the actual warning text was not supplied (or a variable holding it was empty/undefined-coerced) so the user sees the unhelpful string 'message'. It never runs in production (NODE_ENV === 'production' returns early).

Solutions

  1. Find the warnOnce call site emitting the placeholder (extractNonStandardStyleProps or preprocess in style preprocessing) and pass the real deprecation text
  2. Fix argument order: warnOnce(key, message) — ensure the descriptive string is the second argument
  3. If you control the call, replace with the intended message e.g. warnOnce('displayInline', 'display: inline is not a valid...')
  4. Check for upstream fix: this is an internal message bug — update react-native-web to a version where the call site text is correct

Example fix

// before
warnOnce('unsupportedStyle', 'message');
// after
warnOnce('unsupportedStyle', 'Unsupported style prop "' + name + '" will be ignored.');
Defensive patterns

Strategy: validation

Validate before calling

function callWarnOnce(key, message) {
  if (typeof key !== 'string' || key.length === 0) throw new TypeError('warnOnce: key must be a non-empty string');
  if (typeof message !== 'string' || message.length === 0 || message === 'message') throw new TypeError('warnOnce: message must be a descriptive string');
  warnOnce(key, message);
}

Type guard

function hasRealMessage(args) {
  return args.length >= 2 && typeof args[1] === 'string' && args[1].length > 0;
}

Prevention

When it happens

Trigger: Calling warnOnce(key, 'message') with the literal placeholder, or warnOnce(key, someVar) where someVar is undefined/misordered so the second positional string defaults to a template placeholder; in react-native-web internals, extractNonStandardStyleProps and preprocess invoke warnOnce with style-prop deprecation messages — a regression or bad merge passing the wrong literal surfaces this.

Common situations: Upgrading react-native-web and hitting a deprecation warning whose text was mistakenly left as a placeholder; local forks/patches editing the message argument; custom style preprocessing code calling warnOnce with swapped arguments (key and message reversed or message omitted).

Related errors


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

Appendix: source

Thrown at packages/react-native-web/src/modules/warnOnce/index.js:25

 * @flow strict
 */

const warnedKeys: { [string]: boolean, ... } = {};

/**
 * A simple function that prints a warning message once per session.
 *
 * @param {string} key - The key used to ensure the message is printed once.
 *                       This should be unique to the callsite.
 * @param {string} message - The message to print
 */
export function warnOnce(key: string, message: string) {
  if (process.env.NODE_ENV !== 'production') {
    if (warnedKeys[key]) {
      return;
    }

    console.warn(message);

    warnedKeys[key] = true;
  }
}

View on GitHub (pinned to a9de220ba9)