@unif/react-native-design 0.30.0 → 0.30.1
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/jest-setup.js +8 -1
- package/package.json +1 -1
package/jest-setup.js
CHANGED
|
@@ -43,7 +43,9 @@ jest.mock('react-native-gesture-handler', () => ({
|
|
|
43
43
|
// Reanimated 4.6 的官方 mock 已覆盖本库使用的 hooks;真实 native 组件链会在
|
|
44
44
|
// React 19 test renderer 中尝试查 host instance / native style handle,不能用于 Jest。
|
|
45
45
|
// 上游 mock 的 useSharedValue 每次 render 都返回新 Proxy,会让把 shared value 放进
|
|
46
|
-
// effect 依赖数组的组件(本库 ToastHost)
|
|
46
|
+
// effect 依赖数组的组件(本库 ToastHost)反复执行,所以把这个 hook 稳定化。
|
|
47
|
+
// 4.6 的 makeMutable 却只是 identity;RNGH 3 会把它当 shared value 并在 cleanup 里
|
|
48
|
+
// 访问 `.value.delete(...)`,因此也要用官方 mock 的 shared value 形状补齐。
|
|
47
49
|
jest.mock('react-native-reanimated', () => {
|
|
48
50
|
const React = require('react');
|
|
49
51
|
const reanimatedMock = require('react-native-reanimated/mock');
|
|
@@ -56,8 +58,13 @@ jest.mock('react-native-reanimated', () => {
|
|
|
56
58
|
return sharedValueRef.current;
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
function makeMutable(initialValue) {
|
|
62
|
+
return reanimatedMock.useSharedValue(initialValue);
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
return {
|
|
60
66
|
...reanimatedMock,
|
|
67
|
+
makeMutable,
|
|
61
68
|
useSharedValue: useStableSharedValue,
|
|
62
69
|
};
|
|
63
70
|
});
|