@uniflowed/hooks 0.0.0-alpha.40 → 0.0.0-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/async.js CHANGED
@@ -118,6 +118,9 @@ export hook useAsync<T>(
118
118
  // Guarded rather than unconditional: a reload that arrives while a call is
119
119
  // already in flight would otherwise build a new state object, and a new
120
120
  // object is a re-render that changes nothing anyone can see.
121
+ // This effect owns the request lifecycle; the synchronous write marks that
122
+ // external request as pending before its callbacks settle it.
123
+ // uf-lint-disable-next-line react-compiler/set-state-in-effect
121
124
  setState((current) => (current.pending ? current : { ...current, pending: true }));
122
125
 
123
126
  const run = (tries: number) => {
package/events.js CHANGED
@@ -213,6 +213,8 @@ export hook useEventSource(url: string | null, options?: EventSourceOptions): Us
213
213
  useEffect(() => {
214
214
  const Constructor = streamConstructor();
215
215
  if (Constructor == null || url == null || !enabled) {
216
+ // The connection state mirrors whether the external stream exists.
217
+ // uf-lint-disable-next-line react-compiler/set-state-in-effect
216
218
  setStatus(stopped ? "closed" : "idle");
217
219
  return;
218
220
  }
package/lifecycle.js CHANGED
@@ -70,6 +70,9 @@ export hook usePrevious<T>(value: T): T | void {
70
70
  useEffect(() => {
71
71
  previous.current = value;
72
72
  }, [value]);
73
+ // This hook's public value is the last committed render; reading the ref
74
+ // during render is the contract rather than hidden reactive input.
75
+ // uf-lint-disable-next-line react-compiler/refs
73
76
  return previous.current;
74
77
  }
75
78
 
@@ -83,6 +86,9 @@ export hook usePrevious<T>(value: T): T | void {
83
86
  export hook useMounted(): boolean {
84
87
  const [mounted, setMounted] = useState(false);
85
88
  useEffect(() => {
89
+ // The first client render intentionally matches the server, then flips
90
+ // after mount for hydration-sensitive values.
91
+ // uf-lint-disable-next-line react-compiler/set-state-in-effect
86
92
  setMounted(true);
87
93
  }, []);
88
94
  return mounted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/hooks",
3
- "version": "0.0.0-alpha.40",
3
+ "version": "0.0.0-alpha.42",
4
4
  "description": "The React hooks an application writes anyway, prerender-safe, part of the Unified Toolchain for Flow.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,8 +28,8 @@
28
28
  "!*.test.js"
29
29
  ],
30
30
  "dependencies": {
31
- "@uniflowed/core": "0.0.0-alpha.40",
32
- "@uniflowed/react": "0.0.0-alpha.40"
31
+ "@uniflowed/core": "0.0.0-alpha.42",
32
+ "@uniflowed/react": "0.0.0-alpha.42"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=19"
package/timing.js CHANGED
@@ -306,6 +306,9 @@ export hook useNow(millis: number | null = 1000, serverValue: Date | null = null
306
306
 
307
307
  useEffect(() => {
308
308
  if (since != null) {
309
+ // A prerender starts from the server's timestamp for hydration, then
310
+ // adopts the live clock once effects can run.
311
+ // uf-lint-disable-next-line react-compiler/set-state-in-effect
309
312
  setNow(new Date(currentClock().now()));
310
313
  }
311
314
  }, [since]);
@@ -427,6 +430,9 @@ export hook useTimeAgo(
427
430
 
428
431
  const wanted = cadence(Math.abs(now.getTime() - instant));
429
432
  useEffect(() => {
433
+ // The schedule is derived from the ticking external clock. Storing it here
434
+ // lets the interval slow down without adding a second clock source.
435
+ // uf-lint-disable-next-line react-compiler/set-state-in-effect
430
436
  setSchedule(wanted);
431
437
  }, [wanted]);
432
438