@momo-kits/foundation 0.156.1-beta.4 → 0.156.1-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.
- package/Application/TooltipPortal.tsx +10 -12
- package/package.json +1 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
createContext,
|
|
3
|
-
useContext,
|
|
4
|
-
useCallback,
|
|
5
3
|
ReactNode,
|
|
6
|
-
|
|
4
|
+
RefObject,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
7
|
useReducer,
|
|
8
8
|
useRef,
|
|
9
|
-
RefObject,
|
|
10
9
|
} from 'react';
|
|
11
|
-
import {
|
|
10
|
+
import { StyleSheet, View } from 'react-native';
|
|
12
11
|
|
|
13
12
|
interface TooltipPortalContextValue {
|
|
14
13
|
register: (id: string, content: ReactNode) => void;
|
|
@@ -28,7 +27,7 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
|
|
|
28
27
|
const portalsRef = useRef<Map<string, ReactNode>>(new Map());
|
|
29
28
|
const hostRef = useRef<View>(null);
|
|
30
29
|
const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
31
|
-
const pendingUpdateRef = useRef<
|
|
30
|
+
const pendingUpdateRef = useRef<any>(null);
|
|
32
31
|
|
|
33
32
|
const register = useCallback((id: string, content: ReactNode) => {
|
|
34
33
|
portalsRef.current.set(id, content);
|
|
@@ -54,17 +53,16 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
|
|
|
54
53
|
pendingUpdateRef.current = setTimeout(() => {
|
|
55
54
|
forceUpdate();
|
|
56
55
|
pendingUpdateRef.current = null;
|
|
57
|
-
}, 0)
|
|
56
|
+
}, 0);
|
|
58
57
|
}
|
|
59
58
|
}, []);
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
() => ({ register, unregister, portals: portalsRef.current, hostRef }),
|
|
63
|
-
[register, unregister, updateCounter], // Include updateCounter to refresh context
|
|
64
|
-
);
|
|
60
|
+
console.log('updateCounter', updateCounter);
|
|
65
61
|
|
|
66
62
|
return (
|
|
67
|
-
<TooltipPortalContext.Provider
|
|
63
|
+
<TooltipPortalContext.Provider
|
|
64
|
+
value={{ register, unregister, portals: portalsRef.current, hostRef }}
|
|
65
|
+
>
|
|
68
66
|
{children}
|
|
69
67
|
</TooltipPortalContext.Provider>
|
|
70
68
|
);
|