Skip to content

Commit

Permalink
Add deprecation warning for ReactIs.isAsyncMode
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Sep 26, 2018
1 parent 5d6d348 commit 87728c3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/react-is/src/ReactIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
REACT_STRICT_MODE_TYPE,
} from 'shared/ReactSymbols';
import isValidElementType from 'shared/isValidElementType';
import lowPriorityWarning from 'shared/lowPriorityWarning';

export function typeOf(object: any) {
if (typeof object === 'object' && object !== null) {
Expand Down Expand Up @@ -56,6 +57,8 @@ export function typeOf(object: any) {
return undefined;
}

// AsyncMode alias is deprecated along with isAsyncMode
export const AsyncMode = REACT_CONCURRENT_MODE_TYPE;
export const ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
export const ContextConsumer = REACT_CONTEXT_TYPE;
export const ContextProvider = REACT_PROVIDER_TYPE;
Expand All @@ -68,6 +71,16 @@ export const StrictMode = REACT_STRICT_MODE_TYPE;

export {isValidElementType};

// AsyncMode should be deprecated
export function isAsyncMode(object: any) {
lowPriorityWarning(

This comment has been minimized.

Copy link
@gaearon

gaearon Sep 26, 2018

Collaborator

Let’s only warn once. Needs a boolean check.

false,
'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.'
);
return isConcurrentMode(object);
}
export function isConcurrentMode(object: any) {
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
}
Expand Down

0 comments on commit 87728c3

Please sign in to comment.