From d0e3cdd37c00675d77d461bd48e64117b10bd244 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 9 Aug 2017 01:37:51 +0100 Subject: [PATCH] Find callsites that would call toString() if we pass attributes through --- .../shared/hooks/ReactDOMUnknownPropertyHook.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/renderers/dom/shared/hooks/ReactDOMUnknownPropertyHook.js b/src/renderers/dom/shared/hooks/ReactDOMUnknownPropertyHook.js index e68bf66d913fe..a24005bf74c66 100644 --- a/src/renderers/dom/shared/hooks/ReactDOMUnknownPropertyHook.js +++ b/src/renderers/dom/shared/hooks/ReactDOMUnknownPropertyHook.js @@ -126,6 +126,23 @@ var warnUnknownProperties = function(type, props, debugID) { var isValid = validateProperty(type, key, debugID); if (!isValid) { unknownProps.push(key); + var value = props[key]; + if ( + typeof value === 'object' && + value !== null && + !Array.isArray(value) && + value.toString !== Object.prototype.toString + ) { + warning( + false, + 'The %s prop on <%s> is not a known property, and was given an object ' + + 'with a custom toString() method. Remove it, or it will appear in the ' + + 'DOM after a future React update.%s', + key, + type, + getStackAddendum(debugID), + ); + } } }