React hooks for SockJS-client with STOMP messaging protocol.
npm install --save react-use-sockjs
import React, { useState } from 'react';
import useSockjs from 'react-use-sockjs';
export default () => {
const [data, setData] = useState({});
const { sendMessage } = useSockjs({
url: 'http://localhost/ws',
topics: ['/user'],
onMessage: (body, destination) => {
console.log(body, destination);
setData(body);
},
});
return <div>test</div>;
};
Auto generated docs available here.
This project is licensed under the MIT License - see the LICENSE file for details