@radix-ui/react-use-callback-ref 1.0.1 → 1.1.0-rc.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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -25
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +11 -21
- package/dist/index.mjs.map +7 -1
- package/package.json +2 -4
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
3
3
|
* prop or avoid re-executing effects when passed as a dependency
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export { useCallbackRef };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
|
|
3
3
|
* prop or avoid re-executing effects when passed as a dependency
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export { useCallbackRef };
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
26
31
|
|
|
32
|
+
// packages/react/use-callback-ref/src/useCallbackRef.tsx
|
|
33
|
+
var React = __toESM(__require("react"));
|
|
34
|
+
function useCallbackRef(callback) {
|
|
35
|
+
const callbackRef = React.useRef(callback);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
callbackRef.current = callback;
|
|
38
|
+
});
|
|
39
|
+
return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
27
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/useCallbackRef.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = React.useRef(callback);\n\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport { useCallbackRef };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AAMvB,WAAS,eAAkD,UAA4B;AACrF,UAAM,cAAoB,aAAO,QAAQ;AAEzC,IAAM,gBAAU,MAAM;AACpB,kBAAY,UAAU;AAAA,IACxB,CAAC;AAGD,WAAa,cAAQ,MAAO,IAAI,SAAS,YAAY,UAAU,GAAG,IAAI,GAAS,CAAC,CAAC;AAAA,EACnF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
$lwiWj$useEffect(()=>{
|
|
10
|
-
callbackRef.current = callback;
|
|
11
|
-
}); // https://github.com/facebook/react/issues/19240
|
|
12
|
-
return $lwiWj$useMemo(()=>(...args)=>{
|
|
13
|
-
var _callbackRef$current;
|
|
14
|
-
return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
|
|
15
|
-
}
|
|
16
|
-
, []);
|
|
1
|
+
// packages/react/use-callback-ref/src/useCallbackRef.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
function useCallbackRef(callback) {
|
|
4
|
+
const callbackRef = React.useRef(callback);
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
callbackRef.current = callback;
|
|
7
|
+
});
|
|
8
|
+
return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
17
9
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export {$b1b2314f5f9a1d84$export$25bec8c6f54ee79a as useCallbackRef};
|
|
10
|
+
export {
|
|
11
|
+
useCallbackRef
|
|
12
|
+
};
|
|
23
13
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/useCallbackRef.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\n\n/**\n * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a\n * prop or avoid re-executing effects when passed as a dependency\n */\nfunction useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = React.useRef(callback);\n\n React.useEffect(() => {\n callbackRef.current = callback;\n });\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n\nexport { useCallbackRef };\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AAMvB,SAAS,eAAkD,UAA4B;AACrF,QAAM,cAAoB,aAAO,QAAQ;AAEzC,EAAM,gBAAU,MAAM;AACpB,gBAAY,UAAU;AAAA,EACxB,CAAC;AAGD,SAAa,cAAQ,MAAO,IAAI,SAAS,YAAY,UAAU,GAAG,IAAI,GAAS,CAAC,CAAC;AACnF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-use-callback-ref",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -44,7 +44,5 @@
|
|
|
44
44
|
"bugs": {
|
|
45
45
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
46
46
|
},
|
|
47
|
-
"
|
|
48
|
-
"@babel/runtime": "^7.13.10"
|
|
49
|
-
}
|
|
47
|
+
"stableVersion": "1.0.1"
|
|
50
48
|
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAEA;;;GAGG;AACH,+BAAwB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CASrF","sources":["packages/react/use-callback-ref/src/packages/react/use-callback-ref/src/useCallbackRef.tsx","packages/react/use-callback-ref/src/packages/react/use-callback-ref/src/index.ts","packages/react/use-callback-ref/src/index.ts"],"sourcesContent":[null,null,"export { useCallbackRef } from './useCallbackRef';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|