@momo-kits/foundation 0.152.4-beta.4 → 0.152.4-beta.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.
@@ -19,10 +19,12 @@ export type SnackBarCustom = {
19
19
  type: 'custom';
20
20
  content: () => React.ReactNode;
21
21
  heightContent?: number;
22
+ duration?: number;
22
23
  };
23
24
 
24
25
  export type SnackBarToast = {
25
26
  type: 'toast';
27
+ duration?: number;
26
28
  };
27
29
 
28
30
  export type SnackBar = SnackBarCustom | SnackBarToast;
@@ -82,6 +82,22 @@ export const useScreenSnackBar = ({
82
82
  [animateSnackBar],
83
83
  );
84
84
 
85
+ const navigatorRef = useRef(navigator);
86
+
87
+ useEffect(() => {
88
+ navigatorRef.current = navigator;
89
+ }, [navigator]);
90
+
91
+ useEffect(() => {
92
+ if (!snackBarConfig?.duration) return;
93
+
94
+ const timer = setTimeout(() => {
95
+ navigatorRef.current?.hideSnackBar();
96
+ }, snackBarConfig.duration);
97
+
98
+ return () => clearTimeout(timer);
99
+ }, [snackBarConfig?.duration]);
100
+
85
101
  useEffect(() => {
86
102
  navigator?.setSnackBarHost?.({
87
103
  show: showSnackBar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.152.4-beta.4",
3
+ "version": "0.152.4-beta.5",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},