From 68a476103a95be77f4fc7c582e52cc94946de1b4 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 16 Nov 2020 13:09:57 -0800 Subject: [PATCH] Name a bunch of anonymous RN contexts 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 --- Libraries/Components/ScrollView/ScrollViewContext.js | 4 +++- Libraries/Image/ImageAnalyticsTagContext.js | 4 ++++ Libraries/Lists/VirtualizedListContext.js | 3 +++ Libraries/ReactNative/RootTag.js | 4 ++++ Libraries/Text/TextAncestor.js | 8 +++++++- Libraries/Utilities/PerformanceLoggerContext.js | 3 +++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollViewContext.js b/Libraries/Components/ScrollView/ScrollViewContext.js index f774483912d928..894d7f0a56555d 100644 --- a/Libraries/Components/ScrollView/ScrollViewContext.js +++ b/Libraries/Components/ScrollView/ScrollViewContext.js @@ -15,7 +15,9 @@ import * as React from 'react'; type Value = {horizontal: boolean} | null; const ScrollViewContext: React.Context = React.createContext(null); - +if (__DEV__) { + ScrollViewContext.displayName = 'ScrollViewContext'; +} export default ScrollViewContext; export const HORIZONTAL: Value = Object.freeze({horizontal: true}); diff --git a/Libraries/Image/ImageAnalyticsTagContext.js b/Libraries/Image/ImageAnalyticsTagContext.js index ea458bf0c28043..540ae6c02db72d 100644 --- a/Libraries/Image/ImageAnalyticsTagContext.js +++ b/Libraries/Image/ImageAnalyticsTagContext.js @@ -18,4 +18,8 @@ const Context: React.Context = React.createContext( null, ); +if (__DEV__) { + Context.displayName = 'ImageAnalyticsTagContext'; +} + export default Context; diff --git a/Libraries/Lists/VirtualizedListContext.js b/Libraries/Lists/VirtualizedListContext.js index 130315a1b08d57..eddb578ed714c1 100644 --- a/Libraries/Lists/VirtualizedListContext.js +++ b/Libraries/Lists/VirtualizedListContext.js @@ -69,6 +69,9 @@ type Context = $ReadOnly<{ export const VirtualizedListContext: React.Context = React.createContext( null, ); +if (__DEV__) { + VirtualizedListContext.displayName = 'VirtualizedListContext'; +} /** * Resets the context. Intended for use by portal-like components (e.g. Modal). diff --git a/Libraries/ReactNative/RootTag.js b/Libraries/ReactNative/RootTag.js index 24b151544d43b2..e36cafd5744e33 100644 --- a/Libraries/ReactNative/RootTag.js +++ b/Libraries/ReactNative/RootTag.js @@ -19,6 +19,10 @@ export const RootTagContext: React$Context = React.createContext 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; diff --git a/Libraries/Utilities/PerformanceLoggerContext.js b/Libraries/Utilities/PerformanceLoggerContext.js index 5bc3560f0fe1b9..e32f6c249e731b 100644 --- a/Libraries/Utilities/PerformanceLoggerContext.js +++ b/Libraries/Utilities/PerformanceLoggerContext.js @@ -23,4 +23,7 @@ import type {IPerformanceLogger} from './createPerformanceLogger'; const PerformanceLoggerContext: React.Context = React.createContext( GlobalPerformanceLogger, ); +if (__DEV__) { + PerformanceLoggerContext.displayName = 'PerformanceLoggerContext'; +} module.exports = PerformanceLoggerContext;