Skip to content

Commit

Permalink
Better error for ART <Group />
Browse files Browse the repository at this point in the history
Summary: Fixes #3815

Differential Revision: D4295976

Pulled By: javache

fbshipit-source-id: 034690d3bee75217d820d3361136a410a812cd2c
  • Loading branch information
grabbou authored and Martin Konicek committed Dec 12, 2016
1 parent 43d6e8f commit 4a216f6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Libraries/ART/ReactNativeART.js
Expand Up @@ -19,6 +19,7 @@ var ReactNativeViewAttributes = require('ReactNativeViewAttributes');

var createReactNativeComponentClass = require('createReactNativeComponentClass');
var merge = require('merge');
var invariant = require('fbjs/lib/invariant');

// Diff Helpers

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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: <Group /> must be a child of a <Surface />'
);
return (
<NativeGroup
opacity={extractOpacity(props)}
Expand Down

0 comments on commit 4a216f6

Please sign in to comment.