react-use-sockjs
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

react-use-sockjs

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>;
};

API

Auto generated docs available here.

License

This project is licensed under the MIT License - see the LICENSE file for details

Readme

Keywords

none

Package Sidebar

Install

npm i react-use-sockjs

Weekly Downloads

17

Version

0.0.2

License

none

Unpacked Size

21.3 kB

Total Files

6

Last publish

Collaborators

  • qizhancheng