Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brightleaf/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brightleaf/react-hooks - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

17

lib/use-nes.js

@@ -15,2 +15,4 @@ "use strict";

const reducer = (state, action, ...other) => {
const messages = [].concat(state.messages);
switch (action.type) {

@@ -36,6 +38,5 @@ case 'connecting':

case 'message':
const message = [].concat(state.message);
message.push(action.payload.data);
messages.push(action.payload.data);
return { ...state,
message,
messages,
error: null,

@@ -56,5 +57,5 @@ connecting: false

const useNes = (url = 'ws://localhost:4567', subscribe = true) => {
const useNes = (url = 'ws://localhost:4567', subscribe) => {
const [state, dispatch] = (0, _react.useReducer)(reducer, {
message: [],
messages: [],
error: null,

@@ -71,4 +72,4 @@ connecting: true,

});
return new Promise(async (resolve, reject) => {
client.onConnect = update => {
return new Promise(async resolve => {
client.onConnect = () => {
dispatch({

@@ -100,3 +101,3 @@ type: 'connected'

if (subscribe) {
client.subscribe(url, update => {
client.subscribe(subscribe, update => {
dispatch({

@@ -103,0 +104,0 @@ type: 'message',

{
"name": "@brightleaf/react-hooks",
"version": "2.2.0",
"version": "3.0.0",
"description": "Useful react hooks",

@@ -5,0 +5,0 @@ "files": [

@@ -300,3 +300,3 @@ # Brightleaf React Hooks

const { message, error, connecting, connected } = useNes(
const { messages, error, connecting, connected } = useNes(
'wss://kev-pi.herokuapp.com'

@@ -311,7 +311,7 @@ )

const messages = message.map((m, index) => <div key={`key-${index}`}>{m}</div>)
const messageList = messages.map((m, index) => <div key={`key-${index}`}>{m}</div>)
return (
<div className="App">
<h1>Messages from Server</h1>
<div>{messages}</div>
<div>{messageList}</div>
<div>

@@ -318,0 +318,0 @@ <b>Status Messages</b>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc