Skip to content

Commit

Permalink
Don't call valueOf during string concatenation
Browse files Browse the repository at this point in the history
The new Temporal (https://github.com/tc39/proposal-temporal)
 date/time API (currently stage 3)
will throw when calling `valueOf` on instances of most Temporal types.

This behavior breaks react-dom's rendering of Temporal instances because
the current implementation relies on the `+` operator which calls
`valueOf`.

This commit uses String.concat (like Babel does) instead of `+`, which
avoids this problem.
  • Loading branch information
justingrant committed Aug 10, 2021
1 parent e9b2028 commit d69145e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ToStringValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export opaque type ToStringValue =
// around this limitation, we use an opaque type that can only be obtained by
// passing the value through getToStringValue first.
export function toString(value: ToStringValue): string {
return '' + (value: any);
return ''.concat((value: any));
}

export function getToStringValue(value: mixed): ToStringValue {
Expand Down

0 comments on commit d69145e

Please sign in to comment.