diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index 8b739ee9f5..d298cb63e1 100644 --- a/Libraries/ReactNative/AppContainer.js +++ b/Libraries/ReactNative/AppContainer.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule AppContainer + * @format * @flow */ @@ -26,6 +27,7 @@ type Context = { type Props = { children?: React.Children, rootTag: number, + WrapperComponent?: ?ReactClass<*>, }; type State = { inspector: ?React.Element<*>, @@ -62,12 +64,13 @@ class AppContainer extends React.Component { ? null : { + onRequestRerenderApp={updateInspectedViewTag => { this.setState( - (s) => ({mainKey: s.mainKey + 1}), - () => updateInspectedViewTag( - ReactNative.findNodeHandle(this._mainRef) - ) + s => ({mainKey: s.mainKey + 1}), + () => + updateInspectedViewTag( + ReactNative.findNodeHandle(this._mainRef), + ), ); }} />; @@ -93,15 +96,26 @@ class AppContainer extends React.Component { } } + let innerView = ( + { + this._mainRef = ref; + }}> + {this.props.children} + + ); + + const Wrapper = this.props.WrapperComponent; + if (Wrapper) { + innerView = {innerView}; + } return ( - {this._mainRef = ref;}}> - {this.props.children} - + {innerView} {yellowBox} {this.state.inspector} diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index 9bc22fc28f..c51a447c99 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -43,6 +43,7 @@ export type Registry = { sections: Array, runnables: Runnables, }; +export type WrapperComponentProvider = any => ReactClass<*>; const runnables: Runnables = {}; let runCount = 1; @@ -51,6 +52,8 @@ const tasks: Map = new Map(); let componentProviderInstrumentationHook: ComponentProviderInstrumentationHook = (component: ComponentProvider) => component(); +let wrapperComponentProvider: ?WrapperComponentProvider; + /** *