Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add deprecation warning for ReactIs.isAsyncMode
  • Loading branch information
trueadm committed Sep 26, 2018
commit 87728c3ed1501a27efbb6e5d91acce5dfc5ee880
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(
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both this and symbol export rename would be a breaking change technically. Unfortunately we forgot the unstable prefix here. Let’s keep both and add a deprecation warning for isAsyncMode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the change. Did I do it correctly?

return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
}
Expand Down