Skip to content

Commit d69145e

Browse files
committed
Don't call valueOf during string concatenation
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.
1 parent e9b2028 commit d69145e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-dom/src/client/ToStringValue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export opaque type ToStringValue =
1919
// around this limitation, we use an opaque type that can only be obtained by
2020
// passing the value through getToStringValue first.
2121
export function toString(value: ToStringValue): string {
22-
return '' + (value: any);
22+
return ''.concat((value: any));
2323
}
2424

2525
export function getToStringValue(value: mixed): ToStringValue {

0 commit comments

Comments
 (0)