@geops/rvf-mobility-web-component 0.1.60 → 0.1.61
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/CHANGELOG.md +2 -0
- package/index.html +4 -0
- package/index.js +28 -28
- package/package.json +1 -1
- package/src/RvfMobilityMap/RvfMobilityMap.tsx +1 -2
- package/src/utils/hooks/useInitialPermalink.tsx +9 -2
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@geops/rvf-mobility-web-component",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
4
|
"description": "Web components for rvf in the domains of mobility and logistics.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.61",
|
|
6
6
|
"homepage": "https://rvf-mobility-web-component-geops.vercel.app/",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "index.js",
|
|
@@ -602,9 +602,8 @@ function MobilityMapWithDefaultProps(props: MobilityMapProps) {
|
|
|
602
602
|
const propsFromPermalink = useInitialPermalink(
|
|
603
603
|
permalinktemplate || defaultPermalinkTemplate,
|
|
604
604
|
);
|
|
605
|
-
|
|
606
605
|
return (
|
|
607
|
-
<RvfMobilityMap {...defaultProps} {...
|
|
606
|
+
<RvfMobilityMap {...defaultProps} {...props} {...propsFromPermalink} />
|
|
608
607
|
);
|
|
609
608
|
}
|
|
610
609
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from "preact/hooks";
|
|
1
|
+
import { useMemo, useRef } from "preact/hooks";
|
|
2
2
|
|
|
3
3
|
import type { MobilityMapProps } from "../../MobilityMap/MobilityMap";
|
|
4
4
|
|
|
@@ -9,6 +9,8 @@ import type { MobilityMapProps } from "../../MobilityMap/MobilityMap";
|
|
|
9
9
|
const useInitialPermalink = (
|
|
10
10
|
permalinktemplate: string,
|
|
11
11
|
): null | Partial<MobilityMapProps> => {
|
|
12
|
+
const prevProps = useRef<Partial<MobilityMapProps>>(null);
|
|
13
|
+
|
|
12
14
|
const props = useMemo(() => {
|
|
13
15
|
if (!permalinktemplate) {
|
|
14
16
|
return null;
|
|
@@ -70,7 +72,12 @@ const useInitialPermalink = (
|
|
|
70
72
|
return null;
|
|
71
73
|
}, [permalinktemplate]);
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
// We want to apply the value from the url only once
|
|
76
|
+
if (!prevProps.current && props) {
|
|
77
|
+
prevProps.current = props;
|
|
78
|
+
return props;
|
|
79
|
+
}
|
|
80
|
+
return {};
|
|
74
81
|
};
|
|
75
82
|
|
|
76
83
|
export default useInitialPermalink;
|