mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
Better error for ART <Group />
Summary: Fixes #3815 Differential Revision: D4295976 Pulled By: javache fbshipit-source-id: 034690d3bee75217d820d3361136a410a812cd2c
This commit is contained in:
parent
dbcfc2b41f
commit
6feffe1de0
@ -19,6 +19,7 @@ var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
|||||||
|
|
||||||
var createReactNativeComponentClass = require('createReactNativeComponentClass');
|
var createReactNativeComponentClass = require('createReactNativeComponentClass');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
|
var invariant = require('fbjs/lib/invariant');
|
||||||
|
|
||||||
// Diff Helpers
|
// Diff Helpers
|
||||||
|
|
||||||
@ -137,6 +138,14 @@ function childrenAsString(children) {
|
|||||||
// Surface - Root node of all ART
|
// Surface - Root node of all ART
|
||||||
|
|
||||||
class Surface extends React.Component {
|
class Surface extends React.Component {
|
||||||
|
static childContextTypes = {
|
||||||
|
isInSurface: React.PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
getChildContext() {
|
||||||
|
return { isInSurface: true };
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var props = this.props;
|
var props = this.props;
|
||||||
var w = extractNumber(props.width, 0);
|
var w = extractNumber(props.width, 0);
|
||||||
@ -203,8 +212,16 @@ function extractOpacity(props) {
|
|||||||
// ReactART.
|
// ReactART.
|
||||||
|
|
||||||
class Group extends React.Component {
|
class Group extends React.Component {
|
||||||
|
static contextTypes = {
|
||||||
|
isInSurface: React.PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var props = this.props;
|
var props = this.props;
|
||||||
|
invariant(
|
||||||
|
this.context.isInSurface,
|
||||||
|
'ART: <Group /> must be a child of a <Surface />'
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<NativeGroup
|
<NativeGroup
|
||||||
opacity={extractOpacity(props)}
|
opacity={extractOpacity(props)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user