From b5b9e032c2b57aa44afb7141a879d83c8b889feb Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Wed, 4 Dec 2024 06:07:21 -0800 Subject: [PATCH] Fix Android JSC compatibility - replaceAll -> replace (#48076) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48076 JSC for Android does not implement `String.prototype.replaceAll`: {F1971791988} https://github.com/facebook/react-native/pull/47466 introduced a use of it into runtime code, breaking JSC compatibility. This.. replaces it.. with `replace`. Since the argument is already a regex with a `g` modifier, `replaceAll` wasn't necessary anyway. Changelog: [ANDROID][FIXED] Fix JSC by avoiding use of unavailable `str.replaceAll()` Reviewed By: javache Differential Revision: D66712312 fbshipit-source-id: 534b6db6834a2fda46ae8457437de3caa24f4eb0 --- packages/polyfills/console.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/polyfills/console.js b/packages/polyfills/console.js index 22e4ffdc0aa..f4aae2d1c22 100644 --- a/packages/polyfills/console.js +++ b/packages/polyfills/console.js @@ -559,7 +559,7 @@ if (global.nativeLoggingHook) { let originalConsoleError = console.error; console.reportErrorsAsExceptions = true; function stringifySafe(arg) { - return inspect(arg, {depth: 10}).replaceAll(/\n\s*/g, ' '); + return inspect(arg, {depth: 10}).replace(/\n\s*/g, ' '); } console.error = function (...args) { originalConsoleError.apply(this, args);