diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js index 901aecbac6d06..7c9e2fbd25f8a 100644 --- a/packages/react-devtools-shared/src/utils.js +++ b/packages/react-devtools-shared/src/utils.js @@ -126,7 +126,16 @@ export function getUID(): number { } export function utfDecodeString(array: Array<number>): string { - return String.fromCodePoint(...array); + // Avoid spreading the array (e.g. String.fromCodePoint(...array)) + // Functions arguments are first placed on the stack before the function is called + // which throws a RangeError for large arrays. + // See github.com/facebook/react/issues/22293 + let string = ''; + for (let i = 0; i < array.length; i++) { + const char = array[i]; + string += String.fromCodePoint(char); + } + return string; } export function utfEncodeString(string: string): Array<number> {