From 325aa5f31f245ccbf4a0c2869812223cf394fe79 Mon Sep 17 00:00:00 2001 From: nadiia Date: Fri, 7 May 2021 11:43:12 -0700 Subject: [PATCH] [AppContainer] Add back legacy rootTag childContex for 0.65 --- Libraries/ReactNative/AppContainer.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index 5d96cc739b9..7fa4f78a7c8 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) {