How to set state of component in Signalr connection.on()
setState
is a function, so
this.setState = ({ message: msg })
Should instead be
this.setState({ message: msg })
Besides, your function will not be able to access your classe's this
. So instead of a normal anonymous function, you should go with an arrow function that preserves the context:
notifConn.on("ReceiveMessage", (msg) => {
this.setState({ message: msg })
});