mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
150d7f61c6
commit
29f0cedc0a
@@ -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<Props> {
|
||||
hardwareAccelerated: false,
|
||||
};
|
||||
|
||||
static contextTypes: any | {|rootTag: React$PropType$Primitive<number>|} = {
|
||||
rootTag: PropTypes.number,
|
||||
};
|
||||
static contextType: React.Context<RootTag> = RootTagContext;
|
||||
|
||||
_identifier: number;
|
||||
_eventSubscription: ?EmitterSubscription;
|
||||
@@ -203,9 +202,7 @@ class Modal extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const innerChildren = __DEV__ ? (
|
||||
<AppContainer rootTag={this.context.rootTag}>
|
||||
{this.props.children}
|
||||
</AppContainer>
|
||||
<AppContainer rootTag={this.context}>{this.props.children}</AppContainer>
|
||||
) : (
|
||||
this.props.children
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user