use-propagate
Advanced tools
Comparing version 0.0.1-main.b18a4e0 to 0.0.1-main.fd86f9a
{ | ||
"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; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29124