Skip to content

Commit da61446

Browse files
authored
Merge pull request #97594 from callstack-internal/feature/onyx-store-pr-3-v2
[Split #94595] Final PR - Remove useOnyx dependencies arg and bump Onyx
2 parents c7b8272 + 2ae7f26 commit da61446

8 files changed

Lines changed: 11 additions & 69 deletions

File tree

config/eslint/eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ const config = defineConfig([
335335
'rulesdir/require-live-region-for-status-updates': 'error',
336336
'rulesdir/require-a11y-disable-justification': 'error',
337337
'rulesdir/no-direct-pre-insert-fullscreen-under-rhp': 'error',
338-
'rulesdir/no-useOnyx-dependencies-arg': 'error',
339338
'rulesdir/require-locale-for-localized-date-format': 'error',
340339
'rulesdir/prefer-narrow-hook-dependencies': [
341340
'error',

config/eslint/eslint.seatbelt.tsv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@
286286
"../../src/components/ReportActionItem/MoneyReportView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
287287
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
288288
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "react-hooks/set-state-in-effect" 1
289-
"../../src/components/ReportActionItem/MoneyRequestReportPreview/useReportPreviewActionDecision.ts" "rulesdir/no-useOnyx-dependencies-arg" 1
290289
"../../src/components/ReportActionItem/TaskPreview.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
291290
"../../src/components/ReportActionItem/TaskView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
292291
"../../src/components/ReportActionItem/receiptHoverUtils/index.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
@@ -478,7 +477,6 @@
478477
"../../src/hooks/usePrevious.ts" "react-hooks/refs" 1
479478
"../../src/hooks/useReceiptScanDrop.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
480479
"../../src/hooks/useReportScrollManager/index.native.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
481-
"../../src/hooks/useReportTransactionViolations.ts" "rulesdir/no-useOnyx-dependencies-arg" 1
482480
"../../src/hooks/useResetBankAccountModal.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
483481
"../../src/hooks/useResponsiveLayout/index.native.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
484482
"../../src/hooks/useResponsiveLayout/index.ts" "@typescript-eslint/no-unsafe-type-assertion" 1

eslint-plugin-local-rules/no-useOnyx-dependencies-arg.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"react-native-nitro-fetch": "1.5.4",
199199
"react-native-nitro-modules": "0.36.3",
200200
"react-native-nitro-sqlite": "9.6.0",
201-
"react-native-onyx": "3.0.94",
201+
"react-native-onyx": "3.0.95",
202202
"react-native-pager-view": "8.0.0",
203203
"react-native-pdf": "7.0.2",
204204
"react-native-permissions": "^5.4.0",

src/components/ReportActionItem/MoneyRequestReportPreview/useReportPreviewActionDecision.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function useReportPreviewActionDecision({
4747
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`);
4848
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
4949
const [iouReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${iouReportID}`);
50-
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)}, [iouReport?.ownerAccountID]);
50+
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)});
5151

5252
const isDEWPolicy = hasDynamicExternalWorkflow(policy);
5353
const isDEWSubmitPending = hasPendingDEWSubmit(iouReportMetadata, isDEWPolicy);

src/hooks/useOnyx.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import CONST from '@src/CONST';
55
import ONYXKEYS from '@src/ONYXKEYS';
66
import type {SearchResults} from '@src/types/onyx';
77

8-
import type {DependencyList} from 'react';
98
import type {OnyxCollection, OnyxEntry, OnyxKey, OnyxValue, UseOnyxOptions, UseOnyxResult} from 'react-native-onyx';
109

1110
import {use} from 'react';
@@ -73,7 +72,7 @@ function resolveSnapshotAwareResult<TKey extends OnyxKey, TReturnValue>(
7372
/**
7473
* Custom hook for accessing and subscribing to Onyx data with search snapshot support
7574
*/
76-
const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: UseOnyxOptions<TKey, TReturnValue>, dependencies?: DependencyList) => {
75+
const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: UseOnyxOptions<TKey, TReturnValue>) => {
7776
const isSnapshotCompatibleKey = !key.startsWith(ONYXKEYS.COLLECTION.SNAPSHOT) && CONST.SEARCH.SNAPSHOT_ONYX_KEYS.some((snapshotKey) => key.startsWith(snapshotKey));
7877
const isOnSearch = useIsOnSearch();
7978

@@ -98,7 +97,7 @@ const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue
9897
const onyxOptions: UseOnyxOptions<OnyxKey, OnyxValue<OnyxKey>> = {...optionsWithoutSelector, selector};
9998
const snapshotKey = shouldUseSnapshot ? (`${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchHash}` as OnyxKey) : key;
10099

101-
const originalResult = originalUseOnyx(snapshotKey, onyxOptions, dependencies);
100+
const originalResult = originalUseOnyx(snapshotKey, onyxOptions);
102101

103102
// Extract the specific key data from snapshot if in search mode
104103
const result = resolveSnapshotAwareResult<TKey, TReturnValue>(shouldUseSnapshot, !!selector, originalResult, key);
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import ONYXKEYS from '@src/ONYXKEYS';
22
import {transactionViolationsByIDsSelector} from '@src/selectors/TransactionViolations';
3-
import type {Transaction, TransactionViolations} from '@src/types/onyx';
3+
import type {Transaction} from '@src/types/onyx';
44

5-
import type {OnyxCollection} from 'react-native-onyx';
6-
7-
import {useCallback, useMemo} from 'react';
5+
import {useMemo} from 'react';
86

97
import useOnyx from './useOnyx';
108

@@ -14,13 +12,7 @@ import useOnyx from './useOnyx';
1412
*/
1513
function useReportTransactionViolations(transactions: Transaction[]) {
1614
const transactionIDs = useMemo(() => transactions.map((transaction) => transaction.transactionID), [transactions]);
17-
const selectTransactionViolations = useCallback(
18-
(allViolations: OnyxCollection<TransactionViolations>) => transactionViolationsByIDsSelector(transactionIDs)(allViolations),
19-
[transactionIDs],
20-
);
21-
// Pass `transactionIDs` as a dependency so the selector re-runs once the transactions hydrate (otherwise
22-
// it stays closed over the initial empty list and violations would never be selected on first load).
23-
return useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {selector: selectTransactionViolations}, [transactionIDs]);
15+
return useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {selector: transactionViolationsByIDsSelector(transactionIDs)});
2416
}
2517

2618
export default useReportTransactionViolations;

0 commit comments

Comments
 (0)