@tamagui/use-event 1.1.8 → 1.1.10
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/package.json +2 -2
- package/dist/jsx/index.js +0 -3
- package/dist/jsx/index.js.map +0 -7
- package/dist/jsx/useEvent.js +0 -11
- package/dist/jsx/useEvent.js.map +0 -7
- package/dist/jsx/useGet.js +0 -18
- package/dist/jsx/useGet.js.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-event",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
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.1.
|
|
21
|
+
"@tamagui/build": "^1.1.10",
|
|
22
22
|
"react": "^18.2.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
package/dist/jsx/index.js
DELETED
package/dist/jsx/index.js.map
DELETED
package/dist/jsx/useEvent.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useGet } from "./useGet";
|
|
2
|
-
function useEvent(callback) {
|
|
3
|
-
return useGet(callback, defaultValue, true);
|
|
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
|
package/dist/jsx/useEvent.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useEvent.ts"],
|
|
4
|
-
"sourcesContent": ["import { useGet } from './useGet'\n\ntype AnyFunction = (...args: any[]) => any\n\nexport function useEvent<T extends AnyFunction>(callback?: T): T {\n return useGet(callback, defaultValue, true) as T\n}\n\nconst defaultValue = () => {\n throw new Error('Cannot call an event handler while rendering.')\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc;AAIhB,SAAS,SAAgC,UAAiB;AAC/D,SAAO,OAAO,UAAU,cAAc,IAAI;AAC5C;AAEA,MAAM,eAAe,MAAM;AACzB,QAAM,IAAI,MAAM,+CAA+C;AACjE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/jsx/useGet.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
-
const isWeb = process.env.TAMAGUI_TARGET === "web";
|
|
3
|
-
const isClient = typeof window !== "undefined";
|
|
4
|
-
const useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect;
|
|
5
|
-
function useGet(currentValue, initialValue, forwardToFunction) {
|
|
6
|
-
const curRef = useRef(initialValue ?? currentValue);
|
|
7
|
-
useIsomorphicLayoutEffect(() => {
|
|
8
|
-
curRef.current = currentValue;
|
|
9
|
-
});
|
|
10
|
-
return useCallback(
|
|
11
|
-
forwardToFunction ? (...args) => curRef.current?.apply(null, args) : () => curRef.current,
|
|
12
|
-
[]
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
useGet
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=useGet.js.map
|
package/dist/jsx/useGet.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useGet.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useLayoutEffect, useRef } from 'react'\n\nconst isWeb = process.env.TAMAGUI_TARGET === 'web'\nconst isClient = typeof window !== 'undefined'\nconst useIsomorphicLayoutEffect = !isWeb || isClient ? useLayoutEffect : useEffect\n\n// keeps a reference to the current value easily\n\nexport function useGet<A>(\n currentValue: A,\n initialValue?: any,\n forwardToFunction?: boolean,\n): () => A {\n const curRef = useRef<any>(initialValue ?? currentValue)\n useIsomorphicLayoutEffect(() => {\n curRef.current = currentValue\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useCallback(\n forwardToFunction\n ? (...args) => curRef.current?.apply(null, args)\n : () => curRef.current,\n [],\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,aAAa,WAAW,iBAAiB,cAAc;AAEhE,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,WAAW,OAAO,WAAW;AACnC,MAAM,4BAA4B,CAAC,SAAS,WAAW,kBAAkB;AAIlE,SAAS,OACd,cACA,cACA,mBACS;AACT,QAAM,SAAS,OAAY,gBAAgB,YAAY;AACvD,4BAA0B,MAAM;AAC9B,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,SAAO;AAAA,IACL,oBACI,IAAI,SAAS,OAAO,SAAS,MAAM,MAAM,IAAI,IAC7C,MAAM,OAAO;AAAA,IACjB,CAAC;AAAA,EACH;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|