Skip to content

Commit

Permalink
Name a bunch of anonymous RN contexts
Browse files Browse the repository at this point in the history
Summary:
Changelog:
[General] [Changed] - Added (DEV-only) `displayName` to some RN contexts to make them more easy to differentiate when debugging.

Reviewed By: lunaleaps

Differential Revision: D24993068

fbshipit-source-id: 4904259eda50444c2f74700a3540ff4fd02ac322
  • Loading branch information
Brian Vaughn authored and facebook-github-bot committed Nov 16, 2020
1 parent bbd0f03 commit 68a4761
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Libraries/Components/ScrollView/ScrollViewContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import * as React from 'react';
type Value = {horizontal: boolean} | null;

const ScrollViewContext: React.Context<Value> = React.createContext(null);

if (__DEV__) {
ScrollViewContext.displayName = 'ScrollViewContext';
}
export default ScrollViewContext;

export const HORIZONTAL: Value = Object.freeze({horizontal: true});
Expand Down
4 changes: 4 additions & 0 deletions Libraries/Image/ImageAnalyticsTagContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ const Context: React.Context<ContextType> = React.createContext<ContextType>(
null,
);

if (__DEV__) {
Context.displayName = 'ImageAnalyticsTagContext';
}

export default Context;
3 changes: 3 additions & 0 deletions Libraries/Lists/VirtualizedListContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ type Context = $ReadOnly<{
export const VirtualizedListContext: React.Context<?Context> = React.createContext(
null,
);
if (__DEV__) {
VirtualizedListContext.displayName = 'VirtualizedListContext';
}

/**
* Resets the context. Intended for use by portal-like components (e.g. Modal).
Expand Down
4 changes: 4 additions & 0 deletions Libraries/ReactNative/RootTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const RootTagContext: React$Context<RootTag> = React.createContext<RootTa
0,
);

if (__DEV__) {
RootTagContext.displayName = 'RootTagContext';
}

/**
* Intended to only be used by `AppContainer`.
*/
Expand Down
8 changes: 7 additions & 1 deletion Libraries/Text/TextAncestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ const React = require('react');
/**
* Whether the current element is the descendant of a <Text> element.
*/
module.exports = (React.createContext(false): React$Context<$FlowFixMe>);
const TextAncestorContext = (React.createContext(
false,
): React$Context<$FlowFixMe>);
if (__DEV__) {
TextAncestorContext.displayName = 'TextAncestorContext';
}
module.exports = TextAncestorContext;
3 changes: 3 additions & 0 deletions Libraries/Utilities/PerformanceLoggerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ import type {IPerformanceLogger} from './createPerformanceLogger';
const PerformanceLoggerContext: React.Context<IPerformanceLogger> = React.createContext(
GlobalPerformanceLogger,
);
if (__DEV__) {
PerformanceLoggerContext.displayName = 'PerformanceLoggerContext';
}
module.exports = PerformanceLoggerContext;

0 comments on commit 68a4761

Please sign in to comment.