@primer/react 38.29.0-rc.9dc2e199b → 38.29.0-rc.aa262b98e

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.
@@ -1,5 +1,4 @@
1
- import { c } from 'react-compiler-runtime';
2
- import 'react';
1
+ import { useCallback } from 'react';
3
2
  import { reactMajorVersion, isExperimentalReactVersion } from '../utils/environment.js';
4
3
 
5
4
  /**
@@ -42,35 +41,23 @@ const supportsRefCleanup = reactMajorVersion >= 19 || isExperimentalReactVersion
42
41
  * }
43
42
  */
44
43
  function useMergedRefs(refA, refB) {
45
- const $ = c(3);
46
- let t0;
47
- if ($[0] !== refA || $[1] !== refB) {
48
- t0 = value => {
49
- const cleanupA = setRef(refA, value);
50
- const cleanupB = setRef(refB, value);
51
- if (!supportsRefCleanup) {
52
- return;
53
- }
54
- return () => {
55
- if (cleanupA) {
56
- cleanupA();
57
- } else {
58
- setRef(refA, null);
59
- }
60
- if (cleanupB) {
61
- cleanupB();
62
- } else {
63
- setRef(refB, null);
64
- }
65
- };
44
+ return useCallback(value => {
45
+ const cleanupA = setRef(refA, value);
46
+ const cleanupB = setRef(refB, value);
47
+
48
+ // TODO: remove when we are on React 19
49
+ if (!supportsRefCleanup) {
50
+ return;
51
+ }
52
+
53
+ // Only works in React 19. In React 18, the cleanup function will be ignored and the ref will get called with
54
+ // `null` which will be passed to each ref as expected.
55
+ return () => {
56
+ // For object refs and callback refs that don't return cleanups, we still need to pass `null` on cleanup
57
+ if (cleanupA) cleanupA();else setRef(refA, null);
58
+ if (cleanupB) cleanupB();else setRef(refB, null);
66
59
  };
67
- $[0] = refA;
68
- $[1] = refB;
69
- $[2] = t0;
70
- } else {
71
- t0 = $[2];
72
- }
73
- return t0;
60
+ }, [refA, refB]);
74
61
  }
75
62
 
76
63
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "38.29.0-rc.9dc2e199b",
4
+ "version": "38.29.0-rc.aa262b98e",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",