React component for SockJS-client with STOMP messaging protocol.
npm install --save react-stomp
import React from 'react';
import SockJsClient from 'react-stomp';
class SampleComponent extends React.Component {
constructor(props) {
super(props);
}
sendMessage = (msg) => {
this.clientRef.sendMessage('/topics/all', msg);
}
render() {
return (
<div>
<SockJsClient url='http://localhost:8080/ws' topics={['/topics/all']}
onMessage={(msg) => { console.log(msg); }}
ref={ (client) => { this.clientRef = client }} />
</div>
);
}
}
https://react-websocket.herokuapp.com/index
A working implementation using Spring Boot and react-talk can be found at https://github.com/lahsivjar/spring-websocket-template/tree/master/with-sockjs
Auto generated docs available here.
Report any issues or bugs to https://github.com/lahsivjar/react-stomp/issues
componentWillReceiveProps
onConnectFailure
callbackThis project is licensed under the MIT License - see the LICENSE file for details