@etsoo/react 1.5.43 → 1.5.44
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/lib/mu/RLink.js +9 -2
- package/package.json +1 -1
- package/src/mu/RLink.tsx +11 -3
package/lib/mu/RLink.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Link } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { globalApp } from '../app/ReactApp';
|
|
4
|
+
import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
4
5
|
/**
|
|
5
6
|
* Router Link
|
|
6
7
|
* @param props Props
|
|
@@ -9,6 +10,10 @@ import { globalApp } from '../app/ReactApp';
|
|
|
9
10
|
export const RLink = React.forwardRef((props, ref) => {
|
|
10
11
|
// Destruct
|
|
11
12
|
const { href, target, onClick, ...rest } = props;
|
|
13
|
+
const delayed = useDelayedExecutor((href) => {
|
|
14
|
+
// Router push
|
|
15
|
+
globalApp.history.push(href);
|
|
16
|
+
}, 100);
|
|
12
17
|
// Click handler
|
|
13
18
|
const onClickLocl = (event) => {
|
|
14
19
|
if (onClick)
|
|
@@ -19,10 +24,12 @@ export const RLink = React.forwardRef((props, ref) => {
|
|
|
19
24
|
globalApp) {
|
|
20
25
|
// Prevent href action
|
|
21
26
|
event.preventDefault();
|
|
22
|
-
|
|
23
|
-
globalApp.history.push(href);
|
|
27
|
+
delayed.call(undefined, href);
|
|
24
28
|
}
|
|
25
29
|
};
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
return () => delayed.clear();
|
|
32
|
+
}, [delayed]);
|
|
26
33
|
// Component
|
|
27
34
|
return (React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, target: target, ref: ref }));
|
|
28
35
|
});
|
package/package.json
CHANGED
package/src/mu/RLink.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Link, LinkProps } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { globalApp } from '../app/ReactApp';
|
|
4
|
+
import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Router Link
|
|
@@ -12,6 +13,11 @@ export const RLink = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
12
13
|
// Destruct
|
|
13
14
|
const { href, target, onClick, ...rest } = props;
|
|
14
15
|
|
|
16
|
+
const delayed = useDelayedExecutor((href: string) => {
|
|
17
|
+
// Router push
|
|
18
|
+
globalApp.history.push(href);
|
|
19
|
+
}, 100);
|
|
20
|
+
|
|
15
21
|
// Click handler
|
|
16
22
|
const onClickLocl = (
|
|
17
23
|
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
|
@@ -26,12 +32,14 @@ export const RLink = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
26
32
|
) {
|
|
27
33
|
// Prevent href action
|
|
28
34
|
event.preventDefault();
|
|
29
|
-
|
|
30
|
-
// Router push
|
|
31
|
-
globalApp.history.push(href);
|
|
35
|
+
delayed.call(undefined, href);
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
return () => delayed.clear();
|
|
41
|
+
}, [delayed]);
|
|
42
|
+
|
|
35
43
|
// Component
|
|
36
44
|
return (
|
|
37
45
|
<Link
|