Commit 4a216f6 1 parent 43d6e8f commit 4a216f6 Copy full SHA for 4a216f6
File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
19
19
20
20
var createReactNativeComponentClass = require ( 'createReactNativeComponentClass' ) ;
21
21
var merge = require ( 'merge' ) ;
22
+ var invariant = require ( 'fbjs/lib/invariant' ) ;
22
23
23
24
// Diff Helpers
24
25
@@ -137,6 +138,14 @@ function childrenAsString(children) {
137
138
// Surface - Root node of all ART
138
139
139
140
class Surface extends React . Component {
141
+ static childContextTypes = {
142
+ isInSurface : React . PropTypes . bool ,
143
+ } ;
144
+
145
+ getChildContext ( ) {
146
+ return { isInSurface : true } ;
147
+ }
148
+
140
149
render ( ) {
141
150
var props = this . props ;
142
151
var w = extractNumber ( props . width , 0 ) ;
@@ -203,8 +212,16 @@ function extractOpacity(props) {
203
212
// ReactART.
204
213
205
214
class Group extends React . Component {
215
+ static contextTypes = {
216
+ isInSurface : React . PropTypes . bool . isRequired ,
217
+ } ;
218
+
206
219
render ( ) {
207
220
var props = this . props ;
221
+ invariant (
222
+ this . context . isInSurface ,
223
+ 'ART: <Group /> must be a child of a <Surface />'
224
+ ) ;
208
225
return (
209
226
< NativeGroup
210
227
opacity = { extractOpacity ( props ) }
You can’t perform that action at this time.
0 commit comments