@coinbase/cds-common 8.66.1 → 8.66.2

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/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  <!-- template-start -->
10
10
 
11
+ ## 8.66.2 (4/28/2026 PST)
12
+
13
+ #### 🐞 Fixes
14
+
15
+ - Fix: React 19 compatibility issue with useMergeRefs. [[#650](https://github.com/coinbase/cds/pull/650)]
16
+
11
17
  ## 8.66.1 ((4/27/2026, 12:59 PM PST))
12
18
 
13
19
  This is an artificial version bump with no new change.
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Merges multiple refs into a single ref callback. Supports both callback refs
3
+ * and object refs. `null`/`undefined` refs are ignored.
4
+ *
5
+ * The returned callback is referentially stable across renders as long as the
6
+ * underlying refs themselves are stable. This is critical under React 19,
7
+ * which schedules a detach (`oldRef(null)`) followed by an attach
8
+ * (`newRef(node)`) every time a ref-callback's identity changes. Without
9
+ * `useCallback` here, every render would create a new merged callback,
10
+ * triggering React 19's detach/attach lifecycle and — when one of the merged
11
+ * refs synchronously sets state during attach/detach — an infinite update
12
+ * loop ending in `Maximum update depth exceeded`.
13
+ */
1
14
  export declare const useMergeRefs: <T = any>(
2
15
  ...refs: (React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null)[]
3
16
  ) => React.RefCallback<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"useMergeRefs.d.ts","sourceRoot":"","sources":["../../src/hooks/useMergeRefs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,CAAC,GAAG,GAAG,EAClC,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,KAC7E,KAAK,CAAC,WAAW,CAAC,CAAC,CAUrB,CAAC"}
1
+ {"version":3,"file":"useMergeRefs.d.ts","sourceRoot":"","sources":["../../src/hooks/useMergeRefs.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,GAAG,GAAG,EAClC,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,KAC7E,KAAK,CAAC,WAAW,CAAC,CAAC,CAiBrB,CAAC"}
@@ -1,8 +1,23 @@
1
+ import { useCallback } from 'react';
2
+
3
+ /**
4
+ * Merges multiple refs into a single ref callback. Supports both callback refs
5
+ * and object refs. `null`/`undefined` refs are ignored.
6
+ *
7
+ * The returned callback is referentially stable across renders as long as the
8
+ * underlying refs themselves are stable. This is critical under React 19,
9
+ * which schedules a detach (`oldRef(null)`) followed by an attach
10
+ * (`newRef(node)`) every time a ref-callback's identity changes. Without
11
+ * `useCallback` here, every render would create a new merged callback,
12
+ * triggering React 19's detach/attach lifecycle and — when one of the merged
13
+ * refs synchronously sets state during attach/detach — an infinite update
14
+ * loop ending in `Maximum update depth exceeded`.
15
+ */
1
16
  export const useMergeRefs = function () {
2
17
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
3
18
  refs[_key] = arguments[_key];
4
19
  }
5
- return value => {
20
+ return useCallback(value => {
6
21
  refs.forEach(ref => {
7
22
  if (typeof ref === 'function') {
8
23
  ref(value);
@@ -10,5 +25,10 @@ export const useMergeRefs = function () {
10
25
  ref.current = value;
11
26
  }
12
27
  });
13
- };
28
+ },
29
+ // The deps are the spread refs themselves. React's `useCallback` shallow-
30
+ // compares each element of the deps array, so the returned callback stays
31
+ // stable when each underlying ref keeps the same identity across renders.
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ refs);
14
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cds-common",
3
- "version": "8.66.1",
3
+ "version": "8.66.2",
4
4
  "description": "Coinbase Design System - Common",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "@coinbase/cds-icons": "^5.16.0",
42
42
  "@coinbase/cds-illustrations": "^4.38.0",
43
- "@coinbase/cds-mcp-server": "^8.66.1",
43
+ "@coinbase/cds-mcp-server": "^8.66.2",
44
44
  "@coinbase/cds-utils": "^2.3.5",
45
45
  "@modelcontextprotocol/sdk": "^1.13.1",
46
46
  "d3-array": "^3.2.4",