@umituz/react-native-design-system 2.9.35 → 2.9.37
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.37",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -2,24 +2,27 @@
|
|
|
2
2
|
* Performance optimization utilities for safe area hooks
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { useMemo, useRef } from
|
|
6
|
-
import { clearValidationCache } from
|
|
5
|
+
import { useMemo, useRef } from "react";
|
|
6
|
+
import { clearValidationCache } from "./validation";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Memoize options object to prevent unnecessary re-renders
|
|
10
|
-
* Uses
|
|
10
|
+
* Uses shallow comparison for better performance
|
|
11
11
|
*/
|
|
12
|
-
export const useStableOptions = <T extends Record<string, any>>(
|
|
12
|
+
export const useStableOptions = <T extends Record<string, any>>(
|
|
13
|
+
options: T,
|
|
14
|
+
): T => {
|
|
13
15
|
const prevOptionsRef = useRef<T | undefined>(undefined);
|
|
14
16
|
|
|
15
17
|
return useMemo(() => {
|
|
16
|
-
|
|
18
|
+
const prev = prevOptionsRef.current;
|
|
19
|
+
|
|
20
|
+
if (!prev) {
|
|
17
21
|
prevOptionsRef.current = options;
|
|
18
22
|
return options;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
const prevKeys = Object.keys(prevOptionsRef.current);
|
|
25
|
+
const prevKeys = Object.keys(prev);
|
|
23
26
|
const currentKeys = Object.keys(options);
|
|
24
27
|
|
|
25
28
|
if (prevKeys.length !== currentKeys.length) {
|
|
@@ -27,14 +30,13 @@ export const useStableOptions = <T extends Record<string, any>>(options: T): T =
|
|
|
27
30
|
return options;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
const hasChanged = prevKeys.some(key => prevOptionsRef.current![key] !== options[key]);
|
|
33
|
+
const hasChanged = prevKeys.some((key) => prev[key] !== options[key]);
|
|
32
34
|
|
|
33
35
|
if (hasChanged) {
|
|
34
36
|
prevOptionsRef.current = options;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
return prevOptionsRef.current;
|
|
39
|
+
return prevOptionsRef.current ?? options;
|
|
38
40
|
}, [options]);
|
|
39
41
|
};
|
|
40
42
|
|
|
@@ -44,4 +46,4 @@ export const useStableOptions = <T extends Record<string, any>>(options: T): T =
|
|
|
44
46
|
*/
|
|
45
47
|
export const clearPerformanceCaches = (): void => {
|
|
46
48
|
clearValidationCache();
|
|
47
|
-
};
|
|
49
|
+
};
|