From 6feffe1de0dea0ed7aaba2d945c2f06c56f957e6 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 7 Dec 2016 17:03:37 -0800 Subject: [PATCH] Better error for ART Summary: Fixes #3815 Differential Revision: D4295976 Pulled By: javache fbshipit-source-id: 034690d3bee75217d820d3361136a410a812cd2c --- Libraries/ART/ReactNativeART.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Libraries/ART/ReactNativeART.js b/Libraries/ART/ReactNativeART.js index 0ee68bca11825a..419fde98325572 100644 --- a/Libraries/ART/ReactNativeART.js +++ b/Libraries/ART/ReactNativeART.js @@ -19,6 +19,7 @@ var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); var createReactNativeComponentClass = require('createReactNativeComponentClass'); var merge = require('merge'); +var invariant = require('fbjs/lib/invariant'); // Diff Helpers @@ -137,6 +138,14 @@ function childrenAsString(children) { // Surface - Root node of all ART class Surface extends React.Component { + static childContextTypes = { + isInSurface: React.PropTypes.bool, + }; + + getChildContext() { + return { isInSurface: true }; + } + render() { var props = this.props; var w = extractNumber(props.width, 0); @@ -203,8 +212,16 @@ function extractOpacity(props) { // ReactART. class Group extends React.Component { + static contextTypes = { + isInSurface: React.PropTypes.bool.isRequired, + }; + render() { var props = this.props; + invariant( + this.context.isInSurface, + 'ART: must be a child of a ' + ); return (