I planned updating some Promise.all to Promise.allSettled in my React Native - Expo Project but the function does not Exist. i checked all Versions and everything fits but i still cant use the function.
node -v: 14.15.4
expo SDK -v version: ^40.0.1
expo uses react native -v 0.63 in their SDK version. This should not be the problem. This is the error message:
Promise.allSettled is not a function
Does anybody knows a solution to this? Thank you for your help!
For anyone coming across this issue, apparently this was fixed in v64:
https://github.com/facebook/react-native/issues/30236#issuecomment-939286987
For older versions, you can use a simple polyfill:
Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(
promises.map(p => p
.then(value => ({
status: "fulfilled",
value
}))
.catch(reason => ({
status: "rejected",
reason
}))
)
));
React Native uses https://github.com/then/promise for Promises and only in version 8.2.0 it was added with allSettled.
React Ntaive team updated to this version only in 0.70.6 (here list of changes including promise version bumping to 8.3.0 https://github.com/facebook/react-native/releases/tag/v0.70.6)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With