Skip to content

Commit

Permalink
Convert to string before 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 ensures that values are converted to strings before concatenation
is attempted with `+`.
  • Loading branch information
justingrant authored Aug 10, 2021
1 parent da627de commit 4d4fc59
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 '' + String(value: any);
}

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

0 comments on commit 4d4fc59

Please sign in to comment.