在集成到现有项目之后,如何处理意外错误

时间:2015-11-02 06:25:59

标签: android ios migration integration react-native

将React Native集成到现有项目后,如何处理iOS和Android本机代码中的一些意外错误?

例如,React Native视图无法访问网络或出现错误。

谢谢!

1 个答案:

答案 0 :(得分:0)

至少对于网络错误(假设你正在使用FETCH api),你可以添加一个' catch'并显示警告/做其他事情:

fetch('/some/url', {
  method: 'get'
}).then(function(response) {

}).catch(function(err) {
  // Error :(
});