diff --git a/change/react-native-windows-2020-04-29-02-59-44-yellowbox.json b/change/react-native-windows-2020-04-29-02-59-44-yellowbox.json new file mode 100644 index 00000000000..4cf803a33b7 --- /dev/null +++ b/change/react-native-windows-2020-04-29-02-59-44-yellowbox.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Expose YellowBox functionality to native code", + "packageName": "react-native-windows", + "email": "asklar@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-04-29T09:59:44.174Z" +} diff --git a/vnext/ReactUWP/Polyester/IconViewManager.cpp b/vnext/ReactUWP/Polyester/IconViewManager.cpp index 10a43507480..1be6ee0d005 100644 --- a/vnext/ReactUWP/Polyester/IconViewManager.cpp +++ b/vnext/ReactUWP/Polyester/IconViewManager.cpp @@ -65,9 +65,11 @@ void IconShadowNode::updateProperties(const folly::dynamic &&props) { if (propertyName == "color") { if (IsValidColorValue(propertyValue)) glyphs.Fill(BrushFrom(propertyValue)); -#if FUTURE - else if (propertyValue.isNull()) - ; // Log error, must have a color +#ifdef DEBUG + else if (propertyValue.isNull()) { + // Log error, must have a color + YellowBox("IconShadowNode - color property must be non-null"); + } #endif } else if (propertyName == "fontUri") { if (propertyValue.isString()) { diff --git a/vnext/ReactUWP/Views/ShadowNodeBase.cpp b/vnext/ReactUWP/Views/ShadowNodeBase.cpp index 7a4e28e9981..f4d22f70f03 100644 --- a/vnext/ReactUWP/Views/ShadowNodeBase.cpp +++ b/vnext/ReactUWP/Views/ShadowNodeBase.cpp @@ -154,5 +154,12 @@ void ShadowNodeBase::EnsureHandledKeyboardEventHandler() { } } +void ShadowNodeBase::YellowBox(const std::string &message) const noexcept { + const auto instance = GetViewManager()->GetReactInstance().lock(); + if (instance) { + instance->CallJsFunction("RCTLog", "logToConsole", folly::dynamic::array("warn", message)); + } +} + } // namespace uwp } // namespace react diff --git a/vnext/include/ReactUWP/Views/ShadowNodeBase.h b/vnext/include/ReactUWP/Views/ShadowNodeBase.h index a81260c8201..1c988f9be80 100644 --- a/vnext/include/ReactUWP/Views/ShadowNodeBase.h +++ b/vnext/include/ReactUWP/Views/ShadowNodeBase.h @@ -68,6 +68,8 @@ struct REACTWINDOWS_EXPORT ShadowNodeBase : public facebook::react::ShadowNode { return false; } + void YellowBox(const std::string &message) const noexcept; + ViewManagerBase *GetViewManager() const; XamlView GetView() const { return m_view;