RN: Create `RootTag` Type
Summary: Creates a `RootTag` type and refactors the `RootTagContext` module a bit. This creates space for eventually changing `RootTag` into an opaque type that is only created once by `AppContainer`, and only consumed by native abstractions. Changelog: [Internal] (Note: this ignores all push blocking failures!) Reviewed By: cpojer Differential Revision: D21127173 fbshipit-source-id: 60177a6e5e02d6308e87f76d12a271114f8f8fe0
This commit is contained in:
Родитель
0b68f3cf77
Коммит
a850d116dc
|
@ -14,7 +14,7 @@ const EmitterSubscription = require('../vendor/emitter/EmitterSubscription');
|
|||
const PropTypes = require('prop-types');
|
||||
const RCTDeviceEventEmitter = require('../EventEmitter/RCTDeviceEventEmitter');
|
||||
const React = require('react');
|
||||
const RootTagContext = require('./RootTagContext');
|
||||
import {RootTagContext, createRootTag} from './RootTag';
|
||||
const StyleSheet = require('../StyleSheet/StyleSheet');
|
||||
const View = require('../Components/View/View');
|
||||
|
||||
|
@ -128,7 +128,7 @@ class AppContainer extends React.Component<Props, State> {
|
|||
);
|
||||
}
|
||||
return (
|
||||
<RootTagContext.Provider value={this.props.rootTag}>
|
||||
<RootTagContext.Provider value={createRootTag(this.props.rootTag)}>
|
||||
<View style={styles.appContainer} pointerEvents="box-none">
|
||||
{!this.state.hasError && innerView}
|
||||
{this.state.inspector}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
// TODO: Make this into an opaque type.
|
||||
export type RootTag = number;
|
||||
|
||||
export const RootTagContext: React$Context<RootTag> = React.createContext<RootTag>(
|
||||
0,
|
||||
);
|
||||
|
||||
/**
|
||||
* Intended to only be used by `AppContainer`.
|
||||
*/
|
||||
export function createRootTag(rootTag: number): RootTag {
|
||||
return rootTag;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
|
||||
module.exports = (React.createContext<number>(0): React$Context<number>);
|
4
index.js
4
index.js
|
@ -95,7 +95,7 @@ import typeof Platform from './Libraries/Utilities/Platform';
|
|||
import typeof processColor from './Libraries/StyleSheet/processColor';
|
||||
import typeof {PlatformColor} from './Libraries/StyleSheet/PlatformColorValueTypes';
|
||||
import typeof {DynamicColorIOS} from './Libraries/StyleSheet/PlatformColorValueTypesIOS';
|
||||
import typeof RootTagContext from './Libraries/ReactNative/RootTagContext';
|
||||
import typeof {RootTagContext} from './Libraries/ReactNative/RootTag';
|
||||
import typeof DeprecatedColorPropType from './Libraries/DeprecatedPropTypes/DeprecatedColorPropType';
|
||||
import typeof DeprecatedEdgeInsetsPropType from './Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType';
|
||||
import typeof DeprecatedPointPropType from './Libraries/DeprecatedPropTypes/DeprecatedPointPropType';
|
||||
|
@ -468,7 +468,7 @@ module.exports = {
|
|||
return require('./Libraries/ReactNative/requireNativeComponent');
|
||||
},
|
||||
get unstable_RootTagContext(): RootTagContext {
|
||||
return require('./Libraries/ReactNative/RootTagContext');
|
||||
return require('./Libraries/ReactNative/RootTag').RootTagContext;
|
||||
},
|
||||
get unstable_enableLogBox(): () => void {
|
||||
return () =>
|
||||
|
|
Загрузка…
Ссылка в новой задаче