mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove nonstandard Promise.prototype.done implementation
Summary: Changelog: [General][Breaking] - Remove nonstandard Promise.prototype.done `Promise.prototype.done` has been deprecated since D34222667 (https://github.com/facebook/react-native/commit/35800962c16a33eb8e9ff1adfd428cf00bb670d3). Here we remove it from React Native's default Promise polyfill. Users should switch to using standard Promise features like `.then()`, or install their own custom polyfills for advanced use cases. Reviewed By: kodafb Differential Revision: D36001688 fbshipit-source-id: 37f452000c16279280ef6a50b2ce616776377c4e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
20d9d3aa6a
commit
018d5cf985
@@ -11,7 +11,6 @@
|
||||
'use strict';
|
||||
|
||||
const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');
|
||||
const warnOnce = require('../Utilities/warnOnce');
|
||||
|
||||
/**
|
||||
* Set up Promise. The native Promise implementation throws the following error:
|
||||
@@ -37,34 +36,3 @@ if (global?.HermesInternal?.hasPromise?.()) {
|
||||
} else {
|
||||
polyfillGlobal('Promise', () => require('../Promise'));
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
// $FlowFixMe
|
||||
const done = Promise.prototype.done;
|
||||
if (done != null) {
|
||||
let depth = 0;
|
||||
/* eslint-disable no-extend-native */
|
||||
// $FlowFixMe
|
||||
Promise.prototype.done = function () {
|
||||
++depth;
|
||||
try {
|
||||
// Avoid infinite recursion if done() happens to be triggered by warnOnce.
|
||||
if (depth === 1) {
|
||||
// Warn once per unique call stack. Not super efficient, but we're in
|
||||
// __DEV__ and .done() calls are rare to begin with.
|
||||
const key = new Error().stack;
|
||||
warnOnce(
|
||||
key,
|
||||
'Promise.prototype.done(): This nonstandard polyfill ' +
|
||||
'has been deprecated and will be removed in a future release. ' +
|
||||
'Please instead use `.then()`.',
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
--depth;
|
||||
}
|
||||
return done.apply(this, arguments);
|
||||
};
|
||||
/* eslint-enable no-extend-native */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
const Promise = require('promise/setimmediate/es6-extensions');
|
||||
|
||||
require('promise/setimmediate/done');
|
||||
require('promise/setimmediate/finally');
|
||||
|
||||
if (__DEV__) {
|
||||
|
||||
Reference in New Issue
Block a user