From 4d4fc5915eedad6f9c3562a767c7b925f00f7a7f Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Tue, 10 Aug 2021 13:04:26 -0700 Subject: [PATCH] Convert to string before 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 ensures that values are converted to strings before concatenation is attempted with `+`. --- packages/react-dom/src/client/ToStringValue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dom/src/client/ToStringValue.js b/packages/react-dom/src/client/ToStringValue.js index 41826cd404e05..f7b78fd5ae9a8 100644 --- a/packages/react-dom/src/client/ToStringValue.js +++ b/packages/react-dom/src/client/ToStringValue.js @@ -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 {