@uniflowed/hooks 0.9.0 → 0.10.0

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.
Files changed (2) hide show
  1. package/lifecycle.js +12 -2
  2. package/package.json +3 -3
package/lifecycle.js CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  useEffect,
29
29
  useInsertionEffect,
30
30
  useLayoutEffect,
31
+ useMemo,
31
32
  useRef,
32
33
  useState,
33
34
  } from "@uniflowed/react";
@@ -61,7 +62,14 @@ export hook useStableCallback<TArgs extends $ReadOnlyArray<mixed>, TReturn>(
61
62
  latest.current = callback;
62
63
  }, [callback]);
63
64
 
64
- return useCallback((...args: TArgs) => latest.current(...args), []);
65
+ // `useMemo` over a function rather than `useCallback`: the same cache, and
66
+ // `useCallback`'s bound cannot hold a function generic in its arguments.
67
+ return useMemo(
68
+ () =>
69
+ (...args: TArgs) =>
70
+ latest.current(...args),
71
+ [],
72
+ );
65
73
  }
66
74
 
67
75
  /** The value from the previous render, or `undefined` on the first. */
@@ -72,8 +80,10 @@ export hook usePrevious<T>(value: T): T | void {
72
80
  }, [value]);
73
81
  // This hook's public value is the last committed render; reading the ref
74
82
  // during render is the contract rather than hidden reactive input.
75
- // uf-lint-disable-next-line react-compiler/refs
83
+ // uf-lint-disable react-compiler/refs
84
+ // $FlowExpectedError[react-rule-unsafe-ref] the same deliberate read, as Flow's React rules see it.
76
85
  return previous.current;
86
+ // uf-lint-enable react-compiler/refs
77
87
  }
78
88
 
79
89
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/hooks",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
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.9.0",
32
- "@uniflowed/react": "0.9.0"
31
+ "@uniflowed/core": "0.10.0",
32
+ "@uniflowed/react": "0.10.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=19"