From 1a3ef3854bfd718b3bd6665e131b0e0a26d2195c Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Thu, 21 Jul 2016 10:07:25 -0700 Subject: [PATCH] add helpful error to findDOMNode util, closes #147 --- lib/utils/find-dom-node.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/utils/find-dom-node.js b/lib/utils/find-dom-node.js index 2ad55b6d5..3e2e0fb2c 100644 --- a/lib/utils/find-dom-node.js +++ b/lib/utils/find-dom-node.js @@ -7,7 +7,15 @@ */ function findDOMNode(node) { - return window.document.querySelector(`[data-key="${node.key}"]`) + const el = window.document.querySelector(`[data-key="${node.key}"]`) + + if (!el) { + throw new Error(`Unable to find a dom node for "${node.key}". This is +often because of forgetting to add \`props.attributes\` to a component +returned from \`renderNode\`.`) + } + + return el } /**