react-native-in-app-debugger 1.0.46 → 1.0.48

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/index.jsx CHANGED
@@ -28,6 +28,7 @@ import useAnimation from "./useAnimation";
28
28
  import Variables from "./Variables";
29
29
  import Api from "./Api";
30
30
  import useApiInterceptor from "./useApiInterceptor";
31
+ import useStateRef from "./useStateRef";
31
32
 
32
33
  const dimension = Dimensions.get("window");
33
34
 
@@ -60,7 +61,7 @@ export default ({
60
61
  interceptResponse,
61
62
  tabs = [],
62
63
  }) => {
63
- const [blacklists, setB] = useState([]);
64
+ const [blacklists, setB, blacklistRef] = useStateRef([]);
64
65
 
65
66
  const setBlacklists = d => {
66
67
  if (!d) {
@@ -87,7 +88,7 @@ export default ({
87
88
  },[]);
88
89
  }
89
90
 
90
- const { apis, ...restApiInterceptor } = useApiInterceptor(maxNumOfApiToStore, blacklists, interceptResponse);
91
+ const { apis, ...restApiInterceptor } = useApiInterceptor(maxNumOfApiToStore, blacklists, interceptResponse, blacklistRef);
91
92
 
92
93
  const [tab, setTab] = useState("api");
93
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "description": "This library's main usage is to be used by Non-Technical testers during UAT, SIT or any testing phase.",
5
5
  "main": "index.jsx",
6
6
  "scripts": {
package/useAnimation.ts CHANGED
@@ -9,7 +9,7 @@ const touchThreshold = 10;
9
9
  export default (defaultBadgeHeight) => {
10
10
  const cachePosition = useRef({ x: 0, y: 50 });
11
11
  const position = useRef<any>(new Animated.ValueXY(cachePosition.current)).current;
12
- const borderRadius = useRef(new Animated.Value(defaultBorderRadius)).current;
12
+ // const borderRadius = useRef(new Animated.Value(defaultBorderRadius)).current;
13
13
  const badgeHeight = useRef(new Animated.Value(defaultBadgeHeight)).current;
14
14
  const badgeWidth = useRef(new Animated.Value(defaultBadgeWidth)).current;
15
15
  const { width, height } = useWindowDimensions();
@@ -59,7 +59,7 @@ export default (defaultBadgeHeight) => {
59
59
  useEffect(() => {
60
60
  setTimeout(() => setShouldShowDetails(isOpen), isOpen ? 200 : 0);
61
61
  Animated.spring(position, { toValue: isOpen ? { x: 0, y: 0 } : cachePosition.current, ...und }).start();
62
- Animated.spring(borderRadius, { toValue: isOpen ? 0 : defaultBorderRadius, ...und }).start();
62
+ // Animated.spring(borderRadius, { toValue: isOpen ? 0 : defaultBorderRadius, ...und }).start();
63
63
  Animated.spring(badgeHeight, { toValue: isOpen ? height : defaultBadgeHeight, ...und }).start();
64
64
  Animated.spring(badgeWidth, { toValue: isOpen ? width : defaultBadgeWidth, ...und }).start();
65
65
  }, [isOpen]);
@@ -72,7 +72,7 @@ export default (defaultBadgeHeight) => {
72
72
  translateY: position.y,
73
73
  isOpen,
74
74
  setIsOpen,
75
- borderRadius,
75
+ borderRadius: isOpen ? 0 : defaultBorderRadius,
76
76
  shouldShowDetails,
77
77
  };
78
78
  };
@@ -17,7 +17,7 @@ const parse = (data) => {
17
17
  }
18
18
  };
19
19
 
20
- export default (maxNumOfApiToStore, blacklists, interceptResponse) => {
20
+ export default (maxNumOfApiToStore, blacklists, interceptResponse, blacklistRef) => {
21
21
  const [apis, setApis] = useState([]);
22
22
  const [bookmarks, setBookmarks] = useState({});
23
23
 
@@ -35,7 +35,7 @@ export default (maxNumOfApiToStore, blacklists, interceptResponse) => {
35
35
  }, [apis]);
36
36
 
37
37
  const makeRequest = (data) => {
38
- if (blacklists.some((b) => b.url === data.url && b.method === data.method)) return;
38
+ if (blacklistRef.current.some((b) => b.url === data.url && b.method === data.method)) return;
39
39
  const date = new Date();
40
40
  let hour = date.getHours();
41
41
  const minute = (date.getMinutes() + '').padStart(2, '0');
package/useStateRef.js ADDED
@@ -0,0 +1,18 @@
1
+ import { useCallback, useRef, useState, SetStateAction, Dispatch } from "react";
2
+
3
+ const isFunction = (setStateAction) =>
4
+ typeof setStateAction === "function";
5
+
6
+
7
+ export default (initialState) => {
8
+ const [state, setState] = useState(initialState);
9
+ const ref = useRef(state);
10
+
11
+ const dispatch = useCallback((setStateAction) => {
12
+ ref.current = isFunction(setStateAction) ? setStateAction(ref.current) : setStateAction;
13
+
14
+ setState(ref.current);
15
+ }, []);
16
+
17
+ return [state, dispatch, ref];
18
+ };