@radix-ui/react-use-effect-event 0.0.0 → 0.0.1-rc.1744998730501
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.js +2 -5
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +2 -5
- package/dist/index.mjs.map +3 -3
- package/package.json +2 -2
- package/src/use-effect-event.tsx +6 -5
package/dist/index.js
CHANGED
|
@@ -30,17 +30,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
useEffectEvent: () =>
|
|
33
|
+
useEffectEvent: () => useEffectEvent
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/use-effect-event.tsx
|
|
38
38
|
var import_react_use_layout_effect = require("@radix-ui/react-use-layout-effect");
|
|
39
39
|
var React = __toESM(require("react"));
|
|
40
|
-
function
|
|
41
|
-
if (typeof React["useEffectEvent ".trim().toString()] === "function") {
|
|
42
|
-
return React.useEffectEvent(callback);
|
|
43
|
-
}
|
|
40
|
+
function useEffectEvent(callback) {
|
|
44
41
|
const ref = React.useRef(() => {
|
|
45
42
|
throw new Error("Cannot call an event handler while rendering.");
|
|
46
43
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/use-effect-event.tsx"],
|
|
4
|
-
"sourcesContent": ["export { useEffectEvent } from './use-effect-event';\n", "/* eslint-disable react-hooks/rules-of-hooks */\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport * as React from 'react';\n\ntype AnyFunction = (...args: any[]) => any;\n\n/**\n * Designed to approximate the behavior on `experimental_useEffectEvent` as best\n * as possible until its stable release, and back-fill it as a shim as needed.\n */\nexport function useEffectEvent<T extends AnyFunction>(callback?: T): T {\n //
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["export { useEffectEvent } from './use-effect-event';\n", "/* eslint-disable react-hooks/rules-of-hooks */\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport * as React from 'react';\n\ntype AnyFunction = (...args: any[]) => any;\n\n/**\n * Designed to approximate the behavior on `experimental_useEffectEvent` as best\n * as possible until its stable release, and back-fill it as a shim as needed.\n */\nexport function useEffectEvent<T extends AnyFunction>(callback?: T): T {\n // https://github.com/radix-ui/primitives/issues/3485\n // See https://github.com/webpack/webpack/issues/14814\n // if (typeof React['useEffectEvent '.trim().toString()] === 'function') {\n // // @ts-expect-error\n // return React.useEffectEvent(callback);\n // }\n\n const ref = React.useRef<AnyFunction | undefined>(() => {\n throw new Error('Cannot call an event handler while rendering.');\n });\n // @ts-expect-error: See https://github.com/webpack/webpack/issues/14814\n if (typeof React['useInsertionEffect '.trim().toString()] === 'function') {\n React.useInsertionEffect(() => {\n ref.current = callback;\n });\n } else {\n useLayoutEffect(() => {\n ref.current = callback;\n });\n }\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => ref.current?.(...args)) as T, []);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,qCAAgC;AAChC,YAAuB;AAQhB,SAAS,eAAsC,UAAiB;AAQrE,QAAM,MAAY,aAAgC,MAAM;AACtD,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE,CAAC;AAED,MAAI,OAAO,MAAM,sBAAsB,KAAK,EAAE,SAAS,CAAC,MAAM,YAAY;AACxE,IAAM,yBAAmB,MAAM;AAC7B,UAAI,UAAU;AAAA,IAChB,CAAC;AAAA,EACH,OAAO;AACL,wDAAgB,MAAM;AACpB,UAAI,UAAU;AAAA,IAChB,CAAC;AAAA,EACH;AAGA,SAAa,cAAQ,MAAO,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,GAAS,CAAC,CAAC;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
// src/use-effect-event.tsx
|
|
2
2
|
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
function
|
|
5
|
-
if (typeof React["useEffectEvent ".trim().toString()] === "function") {
|
|
6
|
-
return React.useEffectEvent(callback);
|
|
7
|
-
}
|
|
4
|
+
function useEffectEvent(callback) {
|
|
8
5
|
const ref = React.useRef(() => {
|
|
9
6
|
throw new Error("Cannot call an event handler while rendering.");
|
|
10
7
|
});
|
|
@@ -20,6 +17,6 @@ function useEffectEvent2(callback) {
|
|
|
20
17
|
return React.useMemo(() => (...args) => ref.current?.(...args), []);
|
|
21
18
|
}
|
|
22
19
|
export {
|
|
23
|
-
|
|
20
|
+
useEffectEvent
|
|
24
21
|
};
|
|
25
22
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/use-effect-event.tsx"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport * as React from 'react';\n\ntype AnyFunction = (...args: any[]) => any;\n\n/**\n * Designed to approximate the behavior on `experimental_useEffectEvent` as best\n * as possible until its stable release, and back-fill it as a shim as needed.\n */\nexport function useEffectEvent<T extends AnyFunction>(callback?: T): T {\n //
|
|
5
|
-
"mappings": ";AACA,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAQhB,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport * as React from 'react';\n\ntype AnyFunction = (...args: any[]) => any;\n\n/**\n * Designed to approximate the behavior on `experimental_useEffectEvent` as best\n * as possible until its stable release, and back-fill it as a shim as needed.\n */\nexport function useEffectEvent<T extends AnyFunction>(callback?: T): T {\n // https://github.com/radix-ui/primitives/issues/3485\n // See https://github.com/webpack/webpack/issues/14814\n // if (typeof React['useEffectEvent '.trim().toString()] === 'function') {\n // // @ts-expect-error\n // return React.useEffectEvent(callback);\n // }\n\n const ref = React.useRef<AnyFunction | undefined>(() => {\n throw new Error('Cannot call an event handler while rendering.');\n });\n // @ts-expect-error: See https://github.com/webpack/webpack/issues/14814\n if (typeof React['useInsertionEffect '.trim().toString()] === 'function') {\n React.useInsertionEffect(() => {\n ref.current = callback;\n });\n } else {\n useLayoutEffect(() => {\n ref.current = callback;\n });\n }\n\n // https://github.com/facebook/react/issues/19240\n return React.useMemo(() => ((...args) => ref.current?.(...args)) as T, []);\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAQhB,SAAS,eAAsC,UAAiB;AAQrE,QAAM,MAAY,aAAgC,MAAM;AACtD,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE,CAAC;AAED,MAAI,OAAO,MAAM,sBAAsB,KAAK,EAAE,SAAS,CAAC,MAAM,YAAY;AACxE,IAAM,yBAAmB,MAAM;AAC7B,UAAI,UAAU;AAAA,IAChB,CAAC;AAAA,EACH,OAAO;AACL,oBAAgB,MAAM;AACpB,UAAI,UAAU;AAAA,IAChB,CAAC;AAAA,EACH;AAGA,SAAa,cAAQ,MAAO,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,GAAS,CAAC,CAAC;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-use-effect-event",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1-rc.1744998730501",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"react": "^19.0.0",
|
|
32
32
|
"react-dom": "^19.0.0",
|
|
33
33
|
"typescript": "^5.7.3",
|
|
34
|
-
"@repo/eslint-config": "0.0.0",
|
|
35
34
|
"@repo/builder": "0.0.0",
|
|
35
|
+
"@repo/eslint-config": "0.0.0",
|
|
36
36
|
"@repo/typescript-config": "0.0.0"
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://radix-ui.com/primitives",
|
package/src/use-effect-event.tsx
CHANGED
|
@@ -9,11 +9,12 @@ type AnyFunction = (...args: any[]) => any;
|
|
|
9
9
|
* as possible until its stable release, and back-fill it as a shim as needed.
|
|
10
10
|
*/
|
|
11
11
|
export function useEffectEvent<T extends AnyFunction>(callback?: T): T {
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
// https://github.com/radix-ui/primitives/issues/3485
|
|
13
|
+
// See https://github.com/webpack/webpack/issues/14814
|
|
14
|
+
// if (typeof React['useEffectEvent '.trim().toString()] === 'function') {
|
|
15
|
+
// // @ts-expect-error
|
|
16
|
+
// return React.useEffectEvent(callback);
|
|
17
|
+
// }
|
|
17
18
|
|
|
18
19
|
const ref = React.useRef<AnyFunction | undefined>(() => {
|
|
19
20
|
throw new Error('Cannot call an event handler while rendering.');
|