react-native-onyx 3.0.16 → 3.0.18
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/dist/useLiveRef.d.ts +3 -0
- package/dist/useLiveRef.js +3 -0
- package/dist/useOnyx.js +6 -6
- package/package.json +2 -2
package/dist/useLiveRef.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a mutable reference to a value, useful when you need to
|
|
3
3
|
* maintain a reference to a value that may change over time without triggering re-renders.
|
|
4
|
+
*
|
|
5
|
+
* @deprecated This hook breaks the Rules of React, and should not be used.
|
|
6
|
+
* The migration effort to remove it safely is not currently planned.
|
|
4
7
|
*/
|
|
5
8
|
declare function useLiveRef<T>(value: T): import("react").MutableRefObject<T>;
|
|
6
9
|
export default useLiveRef;
|
package/dist/useLiveRef.js
CHANGED
|
@@ -4,6 +4,9 @@ const react_1 = require("react");
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a mutable reference to a value, useful when you need to
|
|
6
6
|
* maintain a reference to a value that may change over time without triggering re-renders.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated This hook breaks the Rules of React, and should not be used.
|
|
9
|
+
* The migration effort to remove it safely is not currently planned.
|
|
7
10
|
*/
|
|
8
11
|
function useLiveRef(value) {
|
|
9
12
|
const ref = (0, react_1.useRef)(value);
|
package/dist/useOnyx.js
CHANGED
|
@@ -51,24 +51,24 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
51
51
|
const connectionRef = (0, react_1.useRef)(null);
|
|
52
52
|
const previousKey = (0, usePrevious_1.default)(key);
|
|
53
53
|
const currentDependenciesRef = (0, useLiveRef_1.default)(dependencies);
|
|
54
|
-
const
|
|
54
|
+
const selector = options === null || options === void 0 ? void 0 : options.selector;
|
|
55
55
|
// Create memoized version of selector for performance
|
|
56
56
|
const memoizedSelector = (0, react_1.useMemo)(() => {
|
|
57
|
-
if (!
|
|
57
|
+
if (!selector) {
|
|
58
58
|
return null;
|
|
59
|
+
}
|
|
59
60
|
let lastInput;
|
|
60
61
|
let lastOutput;
|
|
61
62
|
let lastDependencies = [];
|
|
62
63
|
let hasComputed = false;
|
|
63
64
|
return (input) => {
|
|
64
65
|
const currentDependencies = currentDependenciesRef.current;
|
|
65
|
-
const currentSelector = currentSelectorRef.current;
|
|
66
66
|
// Recompute if input changed, dependencies changed, or first time
|
|
67
67
|
const dependenciesChanged = !(0, fast_equals_1.shallowEqual)(lastDependencies, currentDependencies);
|
|
68
68
|
if (!hasComputed || lastInput !== input || dependenciesChanged) {
|
|
69
69
|
// Only proceed if we have a valid selector
|
|
70
|
-
if (
|
|
71
|
-
const newOutput =
|
|
70
|
+
if (selector) {
|
|
71
|
+
const newOutput = selector(input);
|
|
72
72
|
// Deep equality mode: only update if output actually changed
|
|
73
73
|
if (!hasComputed || !(0, fast_equals_1.deepEqual)(lastOutput, newOutput) || dependenciesChanged) {
|
|
74
74
|
lastInput = input;
|
|
@@ -80,7 +80,7 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
80
80
|
}
|
|
81
81
|
return lastOutput;
|
|
82
82
|
};
|
|
83
|
-
}, [currentDependenciesRef,
|
|
83
|
+
}, [currentDependenciesRef, selector]);
|
|
84
84
|
// Stores the previous cached value as it's necessary to compare with the new value in `getSnapshot()`.
|
|
85
85
|
// We initialize it to `null` to simulate that we don't have any value from cache yet.
|
|
86
86
|
const previousValueRef = (0, react_1.useRef)(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-onyx",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.18",
|
|
4
4
|
"author": "Expensify, Inc.",
|
|
5
5
|
"homepage": "https://expensify.com",
|
|
6
6
|
"description": "State management for React Native",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
"engines": {
|
|
130
|
-
"node": ">=20.19.
|
|
130
|
+
"node": ">=20.19.5",
|
|
131
131
|
"npm": ">=10.8.2"
|
|
132
132
|
},
|
|
133
133
|
"sideEffects": false
|