Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
console.log('Component did mount');
// The compat mode syntax is totally different, converting to v5 syntax
// Client is imported from '@stomp/stompjs'
this.client = new Client();
this.client.configure({
brokerURL: 'ws://localhost:8080/stomp',
onConnect: () => {
console.log('onConnect');
this.client.subscribe('/queue/now', message => {
console.log(message);
this.setState({serverTime: message.body});
});
this.client.subscribe('/topic/greetings', message => {
alert(message.body);
});
},
// Helps during debugging, remove in production