diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index 5d96cc739b9c..7fa4f78a7c80 100644 --- a/Libraries/ReactNative/AppContainer.js +++ b/Libraries/ReactNative/AppContainer.js @@ -14,8 +14,11 @@ import StyleSheet from '../StyleSheet/StyleSheet'; import {type EventSubscription} from '../vendor/emitter/EventEmitter'; import {RootTagContext, createRootTag} from './RootTag'; import type {RootTag} from './RootTag'; +import PropTypes from 'prop-types'; import * as React from 'react'; +type Context = {rootTag: number | RootTag, ...}; + type Props = $ReadOnly<{| children?: React.Node, fabric?: boolean, @@ -43,6 +46,18 @@ class AppContainer extends React.Component { static getDerivedStateFromError: any = undefined; + static childContextTypes: + | any + | {|rootTag: React$PropType$Primitive|} = { + rootTag: PropTypes.number, + }; + + getChildContext(): Context { + return { + rootTag: this.props.rootTag, + }; + } + componentDidMount(): void { if (__DEV__) { if (!global.__RCTProfileIsProfiling) {