react-stomp
react-stomp copied to clipboard
TypeError: Cannot read property 'sendMessage' of undefined. Send to/with different topics/msg
Might be a dumb question, but how do you send messages with different topic and/or msg. I tried doing it in a switch-case, but that resulted in this error.
sendMessage = (messageMap) => { switch (messageMap) { case this.wsGet: this.clientRef.send(this.destinationPrefix + this.wsGet + "/" + this.roomId); break; case this.wsPost: this.clientRef.send(this.destinationPrefix + this.wsPost + "/" + this.roomId, {}, JSON.stringify({ taskName: this.state.taskName, taskDescription: this.state.taskDescription, finished: false })) break; default: console.log("sendMessage case was default...yikes"); break; } };