[英]finally argument showing undefined after react-native upgrade
Recently I upgraded my react-native version from 0.59 to 0.62 and I found out that my .finally functionality broke.最近我将我的 react-native 版本从 0.59 升级到 0.62,我发现我的 .finally 功能坏了。
Actually I am returning the value based on finally argument whether it's success or catch, but suddenly after upgrading, the finally argument started returning undefined and the code started breaking, I am not sure how to fix it.实际上,我正在根据 finally 参数返回值,无论它是成功还是捕获,但是升级后突然,finally 参数开始返回 undefined 并且代码开始中断,我不知道如何修复它。
Code:代码:
return getParsedError().finally((conData?: any) => { // conData is undefined now, earlier it was an object that I am returning from resolve
return Promise.reject(conData || error)
}
We just used async (try catch finally).我们只是使用了 async(最后尝试 catch)。 Alternatively you can replace the finally with a .then and return something from the .catch which will cause the .then to execute.
或者,您可以用 .then 替换 finally 并从 .catch 返回一些内容,这将导致 .then 执行。
幸运的是,经过大量的谷歌搜索后,我发现 finally 在最新的 react-native 版本中的行为有所不同,因为参数现在未定义,所以我添加了一些额外的条件来使我的代码工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.