简体   繁体   English

“预期分配或 function 调用,而是在我的聊天应用程序中看到一个表达式 no-unused-expressions”

[英]“Expected an assignment or function call and instead saw an expression no-unused-expressions” in my chat app

I am working on a React Chat app and during accessing my firebase I got this error "Expected an assignment or function call and instead saw an expression no-unused-expressions"我正在开发一个 React Chat 应用程序,在访问我的 firebase 期间,我收到此错误“预期分配或 function 调用,而是看到一个表达式 no-unused-expressions”

The error occurs in the assignment to this.removeListener.分配给 this.removeListener 时发生错误。

The following are the lines of code in which I got the error:以下是我收到错误的代码行:

this.removeListener = firebase.firestore()
    .collection('Messages')
    .doc(this.groupChatId)
    .collection(this.groupChatId)
    .onSnapshot(Snapshot => {
      Snapshot.docChanges().forEach(change=>{
        if(change.type === LoginString.DOC) {
          this.listMessage.push(change.doc.data());
        }
    })
})

Please help!请帮忙!

I solved the problem by enclosing the entire expression to the right of the "=" in parentheses ie from before "firebase" to the last line after "})".我通过将整个表达式括在括号中的“=”右侧,即从“firebase”之前到“})”之后的最后一行来解决了这个问题。 I think that actually helped in evaluating the expression first and then make the assignment.我认为这实际上有助于首先评估表达式然后进行分配。

Please let me know if it works for any of you also.请让我知道它是否也适用于你们中的任何人。 Thank You!谢谢你!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 得到预期赋值或函数调用的错误,而是看到一个表达式 no-unused-expressions? - Getting the error that Expected an assignment or function call and instead saw an expression no-unused-expressions? 得到预期的赋值或函数调用的错误,而是在反应中看到了一个表达式 no-unused-expressions - getting an error of Expected an assignment or function call and instead saw an expression no-unused-expressions in react 期望一个赋值或函数调用,而是在React中看到一个表达式no-unused-expressions错误 - Expected an assignment or function call and instead saw an expression no-unused-expressions error in React Object.keys-需要一个赋值或函数调用,而是看到一个表达式no-unused-expressions - Object.keys - Expected an assignment or function call and instead saw an expression no-unused-expressions 如何解决这个 期望赋值或函数调用,而是看到一个表达式 no-unused-expressions - how to solve this Expected an assignment or function call and instead saw an expression no-unused-expressions 重定向(反应路由器dom),给出了期望的赋值或函数调用,而是看到了一个表达式no-unused-expressions - Redirect (react router dom) giving Expected an assignment or function call and instead saw an expression no-unused-expressions 在React中导入文件时,获得期望的赋值或函数调用,而是看到一个表达式no-unused-expressions - Getting Expected an assignment or function call and instead saw an expression no-unused-expressions, when import a file in React 反应:期望一个赋值或函数调用,而是看到一个表达式 no-unused-expressions - React: expected an assignment or function call and instead saw an expression no-unused-expressions 期望一个赋值或函数调用,而是看到一个表达式no-unused-expressions(第14/15行) - Expected an assignment or function call and instead saw an expression no-unused-expressions (lines 14/15) ./src/index.js第36行:预期执行赋值或函数调用,而是看到一个表达式no-unused-expressions - ./src/index.js Line 36: Expected an assignment or function call and instead saw an expression no-unused-expressions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM