Skip to content

Commit dd5b0fb

Browse files
committedOct 14, 2024
change call to asyncstoragetestsupport
1 parent b9f2e55 commit dd5b0fb

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed
 

‎packages/default-storage/example/examples/Functional.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
33
import React, { useEffect, useState } from "react";
44
import isEqual from "lodash/isEqual";
55
import {
6+
NativeModules,
67
Platform,
78
ScrollView,
89
StyleSheet,
@@ -129,9 +130,9 @@ function Functional(): JSX.Element {
129130
}
130131
})
131132
.then(async () => {
132-
const AsyncStorageTestSupport = TurboModuleRegistry.get(
133-
"AsyncStorageTestSupport"
134-
);
133+
const AsyncStorageTestSupport = TurboModuleRegistry
134+
? TurboModuleRegistry.get("AsyncStorageTestSupport")
135+
: NativeModules["AsyncStorageTestSupport"];
135136

136137
for (const [currentName, test] of Object.entries(tests)) {
137138
const name = currentName + " with delegate";

‎packages/default-storage/example/examples/MergeItem.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
1010
import React, { useCallback, useState } from "react";
1111
import {
1212
Button,
13+
NativeModules,
1314
StyleSheet,
1415
Text,
1516
TextInput,
@@ -102,6 +103,10 @@ function Merge(): JSX.Element {
102103

103104
const { trait1, trait2 } = traits;
104105

106+
const AsyncStorageTestSupport = TurboModuleRegistry
107+
? TurboModuleRegistry.get("AsyncStorageTestSupport")
108+
: NativeModules["AsyncStorageTestSupport"];
109+
105110
return (
106111
<View>
107112
<View>
@@ -174,28 +179,14 @@ function Merge(): JSX.Element {
174179
<Button
175180
testID="setDelegate_button"
176181
title="Set native delegate"
177-
disabled={
178-
!TurboModuleRegistry.get("AsyncStorageTestSupport")
179-
?.test_setDelegate
180-
}
181-
onPress={() =>
182-
TurboModuleRegistry.get(
183-
"AsyncStorageTestSupport"
184-
)?.test_setDelegate(() => {})
185-
}
182+
disabled={!AsyncStorageTestSupport?.test_setDelegate}
183+
onPress={() => AsyncStorageTestSupport?.test_setDelegate(() => {})}
186184
/>
187185
<Button
188186
testID="unsetDelegate_button"
189187
title="Unset native delegate"
190-
disabled={
191-
!TurboModuleRegistry.get("AsyncStorageTestSupport")
192-
?.test_unsetDelegate
193-
}
194-
onPress={() =>
195-
TurboModuleRegistry.get(
196-
"AsyncStorageTestSupport"
197-
)?.test_unsetDelegate(() => {})
198-
}
188+
disabled={!AsyncStorageTestSupport?.test_unsetDelegate}
189+
onPress={() => AsyncStorageTestSupport?.test_unsetDelegate(() => {})}
199190
/>
200191
</View>
201192

0 commit comments

Comments
 (0)