Skip to content

Commit

Permalink
Updated the utfDecodeString() method to avoid call stack exceeded error
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Sep 15, 2021
1 parent a8cabb5 commit bb7be55
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ export function getUID(): number {
}

export function utfDecodeString(array: Array<number>): string {
return String.fromCodePoint(...array);
// Note that we intentionally map over the Array,
// rather than spreading it (String.fromCodePoint(...array))
// to avoid exceeding the stack call size in the Babel-generated code.
// See github.com/facebook/react/issues/22293#issuecomment-919551764
return array.map(char => String.fromCodePoint(char)).join('');
}

export function utfEncodeString(string: string): Array<number> {
Expand Down

0 comments on commit bb7be55

Please sign in to comment.