You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
### Added
11
11
12
12
- First public release
13
+
- Added `allowPropagateDuringRender` option as a safety measure to prevent multiple re-render, by [@compulim](https://github.com/compulim) in PR [#2](https://github.com/compulim/use-propagate/pull/2)
Copy file name to clipboardExpand all lines: README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,14 @@ export function createPropagation<T>(): {
68
68
69
69
When propagating a value via `useContext`, subscribing nodes will be re-rendered. This behavior may not be desirable for events and certain type of scenarios.
70
70
71
+
### Why I should not call propagate callback function during render-time?
72
+
73
+
When the propagate callback function is called during rendering, a warning message will be printed and propagation will be stopped.
74
+
75
+
This is a safety measure to prevent multiple re-render and potential deadlock situation if listeners save the value to a state and trigger another re-render.
76
+
77
+
If listeners are controlled and would never trigger re-render, you can pass `allowPropagateDuringRender: true` option to ignore this safety measure.
78
+
71
79
### How to get response from the listener or wait for the listener to complete?
72
80
73
81
Modifies the passing value by following the [`FetchEvent.respondWith`](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith) or [`ExtendableEvent.waitUntil`](https://developer.mozilla.org/en-US/docs/Web/API/ExtendableEvent/waitUntil) pattern.
@@ -87,6 +95,8 @@ const MyComponent = () => {
87
95
};
88
96
```
89
97
98
+
Please make sure the propagate callback function is not called during render as it could cause multiple re-render and potential deadlock situation.
99
+
90
100
## Contributions
91
101
92
102
Like us? [Star](https://github.com/compulim/use-propagate/stargazers) us.
0 commit comments