Socket
Socket
Sign inDemoInstall

use-propagate

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-propagate - npm Package Compare versions

Comparing version 0.0.1-main.b18a4e0 to 0.0.1-main.fd86f9a

6

package.json
{
"name": "use-propagate",
"version": "0.0.1-main.b18a4e0",
"description": "Propagates an event to subscribed children.",
"version": "0.0.1-main.fd86f9a",
"description": "Propagates an event to multiple subscribers using React hooks.",
"files": [

@@ -81,5 +81,5 @@ "./lib/"

"@babel/runtime-corejs3": "^7.24.1",
"use-propagate": "^0.0.1-main.b18a4e0",
"use-propagate": "^0.0.1-main.fd86f9a",
"use-ref-from": "^0.0.3"
}
}
# `use-propagate`
Propagates an event to multiple subscribers using React hooks.
Propagates a value to multiple nodes via callback function using React context and hooks.
## Background
This pattern is useful for propagating an event to multiple nodes via a callback mechanism.
This pattern is useful for triggering multiple nodes via callback function.
Unlike setting a value in a [context](https://react.dev/reference/react/createContext), data will be passed via callback function. Subscribe can save the value into state and re-render.
Unlike setting a value in a [context](https://react.dev/reference/react/createContext), invoking a callback function will not trigger re-render. Subscribers can choose to save the value into its state and re-render as needed.

@@ -15,3 +15,3 @@ ## How to use

The following code snippet would send the focus to the text box when the button is tapped.
The following code snippet sends the focus to the text box when the button is tapped.

@@ -61,3 +61,3 @@ ```tsx

export function createPropagation<T>(): {
Provider: ComponentType;
Provider: ComponentType<{ children?: ReactNode | undefined }>;
useListen: (callback: (value: T) => void) => void;

@@ -64,0 +64,0 @@ usePropagate: (value: T) => void;

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