Reconnecting websocket which is NextJS Compatible
npm install nextjs-websocketnextjs-websocket is a easy-to-use NextJS component for websocket communications.
If you need me to build something, just raise an issue:)
This was a fork from react-websocket so s/o to the devs there :)
```
npm install --save nextjs-websocket
`js
import React from 'react'
import { Websocket } from 'nextjs-websocket'
class ProductDetail extends React.Component {
constructor(props) {
super(props)
this.state = {
count: 90
}
}
handleData(data) {
let result = JSON.parse(data)
this.setState({ count: this.state.count + result.movement })
}
render() {
return (
export default ProductDetail
`
#### url
required
The url the websocket connection is listening to.
#### onMessage
required
The callback called when data is received. Data is JSON.parse`'d
#### onOpen
The callback called when the connection is successfully opened.
#### onClose
The callback called when the connection is closed either due to server disconnect or network error.
#### debug
default: false
Set to true to see console logging
#### reconnect
default: true
accelerated reconnection time
