响应本机:未处理的承诺拒绝:TypeError:未定义不是对象

时间:2020-10-12 19:44:03

标签: javascript react-native expo

不幸的是,我在代码中有一个经典的“现在只有上帝知道”的瞬间(或者因为它是由我的团队成员编写的)。 我要返回的项目已经搁置了一段时间,现在返回并尝试更新某些软件包等。我遇到了一些烦人的错误。

当我试图运行我的React Native项目时,主要是这样的

try { 
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress("testname@yahoo.com");

            //receiver email adress
            mailMessage.To.Add("testname@yahoo.com");

            //subject of the email
            mailMessage.Subject = "This is a subject";

            mailMessage.Body = "Body of the email";
            mailMessage.IsBodyHtml = false;

            //SMTP client
            System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("smtp.mail.yahoo.com");
            //port number for Yahoo
            smtpClient.Port = 587;
            //credentials to login in to yahoo account
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = new NetworkCredential("testname@yahoo.com", "password");
            //enabled SSL
            smtpClient.EnableSsl = true;
            //Send an email
            ServicePoint sp = smtpClient.ServicePoint;
            string name = sp.ConnectionName;                
            smtpClient.Send(mailMessage);
        } catch(Exception ex)
        {
            string msg = ex.Message.ToString();
        }

据我所见,该问题应该出现在文件DashBoard.js的第150行。 该行及其周围的代码:

* http://blurred-IP/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:150165:37 in _callee$
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:170:17 in Promise$argument_0
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/regenerator-runtime/runtime.js:169:27 in Promise$argument_0
- node_modules/regenerator-runtime/runtime.js:192:38 in enqueue
- node_modules/regenerator-runtime/runtime.js:216:8 in exports.async
* src/screens/main/DashBoard.js:150:18 in splitServices
* http:blurred-IP/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:150661:69 in fetchEverything$
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:145:19 in Promise.resolve.then$argument_0
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

该列表可能为空?空着吗?

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

将变量值从undefined更改为{}(空对象)应该可以,因为不久前这个问题解决了。

已编辑: 或[]