Remove ConcurrentMode and AsyncMode symbols (#18450)

This API was never released.
This commit is contained in:
Sebastian Markbåge
2020-04-01 10:18:52 -07:00
committed by GitHub
parent d6d5f5aabe
commit e2c6702fca
6 changed files with 14 additions and 33 deletions
-5
View File
@@ -11,8 +11,6 @@ import LRU from 'lru-cache';
import {
isElement,
typeOf,
AsyncMode,
ConcurrentMode,
ContextConsumer,
ContextProvider,
ForwardRef,
@@ -424,9 +422,6 @@ export function getDisplayNameForReactElement(
): string | null {
const elementType = typeOf(element);
switch (elementType) {
case AsyncMode:
case ConcurrentMode:
return 'ConcurrentMode';
case ContextConsumer:
return 'ContextConsumer';
case ContextProvider:
-2
View File
@@ -30,7 +30,6 @@ import {
REACT_FORWARD_REF_TYPE,
REACT_FRAGMENT_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_CONCURRENT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
REACT_SUSPENSE_LIST_TYPE,
REACT_PORTAL_TYPE,
@@ -993,7 +992,6 @@ class ReactDOMServerRenderer {
switch (elementType) {
case REACT_STRICT_MODE_TYPE:
case REACT_CONCURRENT_MODE_TYPE:
case REACT_PROFILER_TYPE:
case REACT_SUSPENSE_LIST_TYPE:
case REACT_FRAGMENT_TYPE: {
+14 -11
View File
@@ -10,8 +10,6 @@
'use strict';
import {
REACT_ASYNC_MODE_TYPE,
REACT_CONCURRENT_MODE_TYPE,
REACT_CONTEXT_TYPE,
REACT_ELEMENT_TYPE,
REACT_FORWARD_REF_TYPE,
@@ -34,8 +32,6 @@ export function typeOf(object: any) {
const type = object.type;
switch (type) {
case REACT_ASYNC_MODE_TYPE:
case REACT_CONCURRENT_MODE_TYPE:
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
@@ -63,9 +59,6 @@ export function typeOf(object: any) {
return undefined;
}
// AsyncMode is deprecated along with isAsyncMode
export const AsyncMode = REACT_ASYNC_MODE_TYPE;
export const ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
export const ContextConsumer = REACT_CONTEXT_TYPE;
export const ContextProvider = REACT_PROVIDER_TYPE;
export const Element = REACT_ELEMENT_TYPE;
@@ -81,6 +74,7 @@ export const Suspense = REACT_SUSPENSE_TYPE;
export {isValidElementType};
let hasWarnedAboutDeprecatedIsAsyncMode = false;
let hasWarnedAboutDeprecatedIsConcurrentMode = false;
// AsyncMode should be deprecated
export function isAsyncMode(object: any) {
@@ -90,15 +84,24 @@ export function isAsyncMode(object: any) {
// Using console['warn'] to evade Babel and ESLint
console['warn'](
'The ReactIs.isAsyncMode() alias has been deprecated, ' +
'and will be removed in React 17+. Update your code to use ' +
'ReactIs.isConcurrentMode() instead. It has the exact same API.',
'and will be removed in React 17+.',
);
}
}
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
return false;
}
export function isConcurrentMode(object: any) {
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
if (__DEV__) {
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
hasWarnedAboutDeprecatedIsConcurrentMode = true;
// Using console['warn'] to evade Babel and ESLint
console['warn'](
'The ReactIs.isConcurrentMode() alias has been deprecated, ' +
'and will be removed in React 17+.',
);
}
}
return false;
}
export function isContextConsumer(object: any) {
return typeOf(object) === REACT_CONTEXT_TYPE;
-5
View File
@@ -84,7 +84,6 @@ import {
REACT_PROFILER_TYPE,
REACT_PROVIDER_TYPE,
REACT_CONTEXT_TYPE,
REACT_CONCURRENT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
REACT_SUSPENSE_LIST_TYPE,
REACT_MEMO_TYPE,
@@ -638,10 +637,6 @@ export function createFiberFromTypeAndProps(
expirationTime,
key,
);
case REACT_CONCURRENT_MODE_TYPE:
fiberTag = Mode;
mode |= ConcurrentMode | BlockingMode | StrictMode;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
mode |= StrictMode;
-8
View File
@@ -32,14 +32,6 @@ export const REACT_PROVIDER_TYPE = hasSymbol
export const REACT_CONTEXT_TYPE = hasSymbol
? Symbol.for('react.context')
: 0xeace;
// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
// (unstable) APIs that have been removed. Can we remove the symbols?
export const REACT_ASYNC_MODE_TYPE = hasSymbol
? Symbol.for('react.async_mode')
: 0xeacf;
export const REACT_CONCURRENT_MODE_TYPE = hasSymbol
? Symbol.for('react.concurrent_mode')
: 0xeacf;
export const REACT_FORWARD_REF_TYPE = hasSymbol
? Symbol.for('react.forward_ref')
: 0xead0;
-2
View File
@@ -8,7 +8,6 @@
*/
import {
REACT_CONCURRENT_MODE_TYPE,
REACT_CONTEXT_TYPE,
REACT_FORWARD_REF_TYPE,
REACT_FRAGMENT_TYPE,
@@ -32,7 +31,6 @@ export default function isValidElementType(type: mixed) {
typeof type === 'function' ||
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
type === REACT_FRAGMENT_TYPE ||
type === REACT_CONCURRENT_MODE_TYPE ||
type === REACT_PROFILER_TYPE ||
type === REACT_STRICT_MODE_TYPE ||
type === REACT_SUSPENSE_TYPE ||