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 committed Aug 10, 2021
1 parent e9b2028 commit ff6a34f
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 ff6a34f

Please sign in to comment.