react-location-handler 1.1.4 → 1.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +12 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-location-handler",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "files": [
package/src/index.js CHANGED
@@ -4,6 +4,13 @@ import { useLocation } from "react-router-dom";
4
4
 
5
5
  import { useMemo } from "react";
6
6
 
7
+ /**
8
+ *
9
+ * @param {any} hiddenPath
10
+ * @param {any} defaultElement
11
+ * @returns {{isHidden : boolean , Hide : Function , Show : Function , getRanderContent : Function}}
12
+ */
13
+
7
14
  const useHandleLocation = (hiddenPath = [], defaultElement = null) => {
8
15
 
9
16
  const { pathname } = useLocation();
@@ -17,41 +24,29 @@ const useHandleLocation = (hiddenPath = [], defaultElement = null) => {
17
24
 
18
25
  return (path) => pathSet.has(path)
19
26
 
20
- }, [hiddenPath])
27
+ }, [hiddenPath]);
21
28
 
22
29
  const isHidden = checkHidden(pathname);
23
30
 
24
-
25
31
  const getRanderContent = (element) => {
26
-
27
32
  const content = element || defaultElement;
28
33
 
29
34
  if (typeof content === 'function') {
30
-
31
35
  return content();
32
-
33
36
  }
34
-
35
-
36
-
37
+
37
38
  return content;
38
-
39
39
  };
40
- const Hide = (overridePath = [], elements) => {
41
40
 
41
+ const Hide = (overridePath = [], elements) => {
42
42
  const condition = overridePath.length > 0 ? overridePath.includes(pathname) : isHidden;
43
-
44
43
  return condition ? null : getRanderContent(elements);
45
-
46
- }
44
+ };
47
45
 
48
46
  const Show = (overridePath = [], elements) => {
49
-
50
47
  const condition = overridePath.length > 0 ? overridePath.includes(pathname) : isHidden;
51
-
52
48
  return condition ? getRanderContent(elements) : null;
53
-
54
- }
49
+ };
55
50
 
56
51
  return { isHidden, Hide, Show, getRanderContent }
57
52
  }