diff --git a/packages/react/src/ReactContext.js b/packages/react/src/ReactContext.js index af97b903cf734..cbcd3373c8166 100644 --- a/packages/react/src/ReactContext.js +++ b/packages/react/src/ReactContext.js @@ -120,11 +120,6 @@ export function createContext( return context.Consumer; }, }, - displayName: { - get() { - return context.displayName; - }, - }, }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty context.Consumer = Consumer; diff --git a/packages/react/src/__tests__/ReactContextValidator-test.js b/packages/react/src/__tests__/ReactContextValidator-test.js index f751dc70727e0..0123d7091755f 100644 --- a/packages/react/src/__tests__/ReactContextValidator-test.js +++ b/packages/react/src/__tests__/ReactContextValidator-test.js @@ -18,7 +18,6 @@ let PropTypes; let React; let ReactDOM; -let ReactDOMServer; let ReactTestUtils; describe('ReactContextValidator', () => { @@ -28,7 +27,6 @@ describe('ReactContextValidator', () => { PropTypes = require('prop-types'); React = require('react'); ReactDOM = require('react-dom'); - ReactDOMServer = require('react-dom/server'); ReactTestUtils = require('react-dom/test-utils'); }); @@ -673,26 +671,4 @@ describe('ReactContextValidator', () => { 'Warning: ComponentB: Function components do not support contextType.', ); }); - - it('should honor a displayName if set on the context type', () => { - const Context = React.createContext(null); - Context.displayName = 'MyContextType'; - function Validator() { - return null; - } - Validator.propTypes = {dontPassToSeeErrorStack: PropTypes.bool.isRequired}; - - expect(() => { - ReactDOMServer.renderToStaticMarkup( - - {() => } - , - ); - }).toErrorDev( - 'Warning: Failed prop type: The prop `dontPassToSeeErrorStack` is marked as required in `Validator`, but its value is `undefined`.\n' + - ' in Validator (at **)\n' + - ' in MyContextType.Consumer (at **)\n' + - ' in MyContextType.Provider (at **)', - ); - }); }); diff --git a/packages/shared/getComponentName.js b/packages/shared/getComponentName.js index 9817ea21963ee..e458338982dce 100644 --- a/packages/shared/getComponentName.js +++ b/packages/shared/getComponentName.js @@ -24,7 +24,6 @@ import { REACT_BLOCK_TYPE, } from 'shared/ReactSymbols'; import {refineResolvedLazyComponent} from 'shared/ReactLazyComponent'; -import type {ReactContext, ReactProviderType} from 'shared/ReactTypes'; function getWrappedName( outerType: mixed, @@ -38,10 +37,6 @@ function getWrappedName( ); } -function getContextName(type: ReactContext) { - return type.displayName || 'Context'; -} - function getComponentName(type: mixed): string | null { if (type == null) { // Host root, text node or just invalid type. @@ -78,11 +73,9 @@ function getComponentName(type: mixed): string | null { if (typeof type === 'object') { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: - const context: ReactContext = (type: any); - return getContextName(context) + '.Consumer'; + return 'Context.Consumer'; case REACT_PROVIDER_TYPE: - const provider: ReactProviderType = (type: any); - return getContextName(provider._context) + '.Provider'; + return 'Context.Provider'; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, 'ForwardRef'); case REACT_MEMO_TYPE: