From fef8bc33df6b57803232f0a3b6bd7613e564170a Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 24 Apr 2020 21:24:27 -0700 Subject: [PATCH] Fabric: Added assert in ShadowNode Summary: It's not allowed to return nullptr from the callback. The assert ensures it which is helpful during development. Probably, we should consider using `gsl::not_null<>` here. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D21149891 fbshipit-source-id: a5f77b35029f22b499491721036405682f812a38 --- ReactCommon/fabric/core/shadownode/ShadowNode.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index cf88b5a6a78..f54fedcf22b 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -263,6 +263,10 @@ ShadowNode::Unshared ShadowNode::cloneTree( auto newShadowNode = callback(*oldShadowNode); + assert( + newShadowNode && + "`callback` returned `nullptr` which is not allowed value."); + auto childNode = newShadowNode; for (auto it = ancestors.rbegin(); it != ancestors.rend(); ++it) {