Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const useNes = (url = 'ws://localhost:4567', subscribe) => {
const [state, dispatch] = useReducer(reducer, {
messages: [],
error: null,
connecting: true,
connected: false,
})
var client = new Nes.Client(url)
useEffect(() => {
const connectClient = async () => {
dispatch({ type: 'connecting', payload: {} })
return new Promise(async resolve => {
client.onConnect = () => {
dispatch({ type: 'connected' })
return resolve()
}
client.onDisconnect = () => {
dispatch({ type: 'disconnected' })
return resolve()
}
await client.connect()
client.onUpdate = update => {