From a19fec2a42e1aa5ae1e99b7c37978628904e592b Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 3 Sep 2019 07:15:32 -0700 Subject: [PATCH] Split out unknown component into DummyComponent --- modern/src/App.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modern/src/App.js b/modern/src/App.js index 6727a58c..b5135973 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -507,6 +507,11 @@ const NODE_NAME_TO_COMPONENT = { text: Text, }; +function DummyComponent({ node, children }) { + console.warn("Unknown node type", node.name); + return <>{children}; +} + // Given a skin XML node, pick which component to use, and render it. function XmlNode({ node }) { const { name } = node; @@ -521,7 +526,7 @@ function XmlNode({ node }) { return null; } useJsUpdates(node); - const Component = NODE_NAME_TO_COMPONENT[name]; + const Component = NODE_NAME_TO_COMPONENT[name] || DummyComponent; const childNodes = node.children || []; const children = childNodes.map( (childNode, i) => @@ -529,14 +534,6 @@ function XmlNode({ node }) { ) ); - if (Component == null) { - console.warn("Unknown node type", name); - if (childNodes.length) { - return <>{children}; - } - return null; - } - return ( {children}