Home > Software engineering >  How to solve the malformed arrow value error?
How to solve the malformed arrow value error?

Time:09-26

I have this function:

const removeChatTyping = (data) => {
    getTypingMessages(data).fadeOut(function () {
      $(this).remove();
    });
  }

I don't need the "fadeout" part so I took it out like this:

const removeChatTyping = (data) => {
    getTypingMessages(data) => {
      $(this).remove();
    };
  }

but I get an error that says malformed arrow. How can I take the fade out part smoothly?

I'd appreciate any answers that can lead me to solve this.

CodePudding user response:

If you want to remove it immediately when the function is called, then you don't need a callback (or attempted callback), just call .remove() immediately.

const removeChatTyping = (data) => {
    getTypingMessages(data);
    $(this).remove();
}
  • Related