From 29f0cedc0ad2a52b73f580cfb31dcb1efefefa85 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Tue, 2 Jun 2020 11:12:20 -0700 Subject: [PATCH] Remove usage of legacy context API in modal (#29002) Summary: Remove usage of the legacy context API in Modal in favor of the new context API. Closes https://github.com/facebook/react-native/issues/28103 Pull Request resolved: https://github.com/facebook/react-native/pull/29002 Test Plan: Run RNTester app and test the Modal example. Also add a `console.warn` to make sure we get the correct context value. Differential Revision: D21793993 Pulled By: TheSavior fbshipit-source-id: de2a30cbd46507bfa73a563d2429c5a7f0e320c9 --- Libraries/Modal/Modal.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index b81334c91db..3e9f0331a80 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -11,13 +11,14 @@ 'use strict'; const AppContainer = require('../ReactNative/AppContainer'); +const {RootTagContext} = require('../ReactNative/RootTag'); const I18nManager = require('../ReactNative/I18nManager'); -const PropTypes = require('prop-types'); const React = require('react'); const ScrollView = require('../Components/ScrollView/ScrollView'); const StyleSheet = require('../StyleSheet/StyleSheet'); const View = require('../Components/View/View'); +import type {RootTag} from '../ReactNative/RootTag'; import type {ViewProps} from '../Components/View/ViewPropTypes'; import type {DirectEventHandler} from '../Types/CodegenTypes'; import type EmitterSubscription from '../vendor/emitter/EmitterSubscription'; @@ -148,9 +149,7 @@ class Modal extends React.Component { hardwareAccelerated: false, }; - static contextTypes: any | {|rootTag: React$PropType$Primitive|} = { - rootTag: PropTypes.number, - }; + static contextType: React.Context = RootTagContext; _identifier: number; _eventSubscription: ?EmitterSubscription; @@ -203,9 +202,7 @@ class Modal extends React.Component { } const innerChildren = __DEV__ ? ( - - {this.props.children} - + {this.props.children} ) : ( this.props.children );