@tamagui/use-event 1.74.2 → 1.74.4
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useGet } from "./useGet";
|
|
2
|
+
function useEvent(callback) {
|
|
3
|
+
return useGet(callback, defaultValue, !0);
|
|
4
|
+
}
|
|
5
|
+
const defaultValue = () => {
|
|
6
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useEvent
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useEvent.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
const isWeb = !1, isClient = typeof window < "u", useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect;
|
|
3
|
+
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
4
|
+
const curRef = useRef(initialValue ?? currentValue);
|
|
5
|
+
return useIsomorphicLayoutEffect(() => {
|
|
6
|
+
curRef.current = currentValue;
|
|
7
|
+
}), useCallback(
|
|
8
|
+
forwardToFunction ? (...args) => curRef.current?.apply(null, args) : () => curRef.current,
|
|
9
|
+
[]
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useGet
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useGet.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useGet.ts"],
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa,WAAW,iBAAiB,cAAc;AAEhE,MAAM,QAAQ,IACR,WAAW,OAAO,SAAW,KAC7B,4BAA4B,CAAC,SAAS,WAAW,kBAAkB;AAIlE,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,SAAS,OAAY,gBAAgB,YAAY;AACvD,mCAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC,GAEM;AAAA,IACL,oBACI,IAAI,SAAS,OAAO,SAAS,MAAM,MAAM,IAAI,IAC7C,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-event",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.4",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@tamagui/build": "1.74.
|
|
21
|
+
"@tamagui/build": "1.74.4",
|
|
22
22
|
"react": "^18.2.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|