stomp
function App() {
const [stompClient, setStompClient] = useState(null);
useEffect(() => {
//https://medium.com/practo-engineering/websockets-in-react-the-component-way-368730334eef
const socket = SockJS(ENDPOINT);
const stompClient = Stomp.over(socket);
stompClient.connect({}, () => {
stompClient.subscribe('/topic/greetings', (data) => {
console.log(data);
});
});
setStompClient(stompClient);
}, []);
return (
<div>
<a href='#' onClick={() => {
stompClient.send('/app/hello', {}, JSON.stringify({
name: 'hi'
}))
}}>Send message</a>
</div>
)
}